Skip to content

Commit

Permalink
[sc-119944] add logging query to monitor (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophia-hanley authored Jan 27, 2025
1 parent 9e2b2e3 commit b25feef
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

## 1.7.0

Added:
* Adds support for logging query in the `chronosphere_monitor` resource.

## 1.6.2

Added:
Expand Down
1 change: 1 addition & 0 deletions chronosphere/intschema/monitor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions chronosphere/resource_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (monitorConverter) toModel(
SeriesConditions: seriesConditions,
SignalGrouping: monitorSignalGroupingToModel(m.SignalGrouping),
Slug: m.Slug,
LoggingQuery: m.Query.LoggingExpr,
}, nil
}

Expand All @@ -155,6 +156,7 @@ func (monitorConverter) fromModel(
Query: intschema.MonitorQuery{
GraphiteExpr: m.GraphiteQuery,
PrometheusExpr: m.PrometheusQuery,
LoggingExpr: m.LoggingQuery,
},
SeriesConditions: monitorSeriesConditionsFromModel(m.SeriesConditions),
Annotations: m.Annotations,
Expand Down
4 changes: 4 additions & 0 deletions chronosphere/tfschema/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ var Monitor = map[string]*schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"logging_expr": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions examples/monitors-logging/collection.tf
1 change: 1 addition & 0 deletions examples/monitors-logging/email.tf
16 changes: 16 additions & 0 deletions examples/monitors-logging/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "chronosphere_monitor" "monitor_with_logging_query" {
name = "Monitor With Logging Query"
collection_id = chronosphere_collection.infra.id
query {
logging_expr = <<-EOF
service = "nginx" | make-series by chronosphere_namespace
EOF
}
series_conditions {
condition {
severity = "warn"
value = 20
op = "GT"
}
}
}
1 change: 1 addition & 0 deletions examples/monitors-logging/team.tf
1 change: 1 addition & 0 deletions examples/monitors-logging/version.tf

0 comments on commit b25feef

Please sign in to comment.