Skip to content

PC-18992: Add multi-query support for Sumo Logic metrics#545

Open
nikodemrafalski wants to merge 5 commits intomainfrom
PC-18992-implement-multi-query-support-for-sumo-logic-metrics-integration
Open

PC-18992: Add multi-query support for Sumo Logic metrics#545
nikodemrafalski wants to merge 5 commits intomainfrom
PC-18992-implement-multi-query-support-for-sumo-logic-metrics-integration

Conversation

@nikodemrafalski
Copy link
Contributor

@nikodemrafalski nikodemrafalski commented Mar 4, 2026

Summary

Add multi-query (ABC pattern) support for Sumo Logic metrics integration, aligning the Terraform provider with the updated nobl9-go SDK.

Changes

Sumo Logic Multi-Query Support

  • Added queries block to the sumologic schema, enabling multiple named queries (rows A–F) that can reference each other
  • Deprecated the singular query attribute in favor of the new queries block
  • Added schema validation ensuring query and queries are mutually exclusive
  • Added plan drift handling for the new queries attribute

ThousandEyes Fix

  • Added account_group_id attribute to the thousandeyes schema to match the updated SDK

Other

  • Bumped nobl9-go and other dependencies
  • Updated documentation with Sumo Logic multi-query examples
  • Added unit and acceptance test coverage

Example Usage

query {
  sumologic {
    type        = "metrics"
    quantization = "15s"
    rollup      = "Avg"
    queries {
      row_id = "A"
      query  = "metric=cpu_idle"
    }
    queries {
      row_id = "B"
      query  = "#A + 1"
    }
  }
}

Test Plan

  • Unit tests pass (make test/unit)
  • Acceptance tests pass against dev-demo-3.nobl9.dev (all 160+ SLO subtests)

Part of PC-18992.

- Bump nobl9-go to include SumoLogicQuery struct
- Add 'queries' ListNestedBlock to sumologic schema (row_id + query)
- Deprecate singular 'query' attribute (now Optional)
- Update SumoLogicModel with Queries slice and SumoLogicQueryModel
- Handle bi-directional conversion in sumoLogicToModel/modelToSumoLogic
@n9-machine-user n9-machine-user added the go Pull requests that update Go code label Mar 4, 2026
Update nobl9-go to include multi-query review fixes.
Null out legacy query field when multi-query is present to prevent
perpetual plan drift. Add ConflictsWith validators ensuring query and
queries are mutually exclusive, and a custom validator forbidding
queries block for logs type. Fix template test helper to render all
slice elements and add multi-query golden file test. Regenerate docs.
@nikodemrafalski nikodemrafalski marked this pull request as ready for review March 19, 2026 14:03
Copy link
Member

@skrolikiewicz skrolikiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Overall well-structured PR that follows existing codebase conventions. Some positive highlights:

  • Plan drift handling is well implemented — types.StringNull() on Query when Queries is populated prevents perpetual drift
  • Bidirectional ConflictsWith validators are correctly set up on both query and queries
  • Custom sumoLogicQueriesTypeValidator cleanly prevents queries for logs type
  • Template rendering fix (all slice elements instead of just first) is safe — existing tests use single-element slices so no breakage
  • Model type change (stringtypes.String) is correct and doesn't require a schema version bump
  • ThousandEyes account_group_id addition follows established codebase patterns

Left a few suggestions inline — nothing blocking, just ideas to harden validation and improve test coverage.

Optional: true,
Description: "Query for the metrics. Deprecated: use 'queries' block instead.",
DeprecationMessage: "Use 'queries' block instead for multi-query support.",
Validators: []validator.String{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConflictsWith ensures mutual exclusivity, but there's no validation that at least one of query or queries is provided. A user could submit a sumologic block with only type set and get a confusing API-level error. Consider adding stringvalidator.AtLeastOneOf(path.MatchRelative().AtParent().AtName("queries")) here.

Blocks: map[string]schema.Block{
"queries": schema.ListNestedBlock{
Description: "Multi-query configuration for metrics type (ABC pattern). Each query row has a row ID (A-F) and a query string. The SLI result is taken from the row with the highest letter ID (e.g., if rows A, B, C are defined, the result comes from row C).",
Validators: []validator.List{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No validation for duplicate row_id values. A user could define two queries both with row_id = "A". Either add a custom validator checking uniqueness, or confirm the SDK catches this and document that decision.


### Optional

> **NOTE**: [Write-only arguments](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments) are supported in Terraform 1.11 and later.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removal (write-only arguments note + retrieve_historical_data_from type change) appears unrelated to the Sumo Logic multi-query feature. Consider splitting into a separate commit or calling it out in the PR description.

return model
},
},
"sumologic multi-query": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding negative test cases: (1) queries with type = "logs" to verify the custom validator, (2) both query and queries empty, (3) both set simultaneously. These are cheap to add and protect against regressions.

@paulina-n9
Copy link
Contributor

Verified CRUD operations for both Agent and Direct modes that support the ABC pattern.

Additionally, confirmed that unsupported configurations (Agent, Direct, and Logs data types) are handled correctly.

@paulina-n9 paulina-n9 added the passed-testing Added by QA when tests have passed label Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code passed-testing Added by QA when tests have passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants