diff --git a/docs/data-sources/bar_gauge.md b/docs/data-sources/bar_gauge.md index 7a0a7b3..8a440ec 100644 --- a/docs/data-sources/bar_gauge.md +++ b/docs/data-sources/bar_gauge.md @@ -60,7 +60,7 @@ data "gdashboard_bar_gauge" "jobs_processed" { prometheus { uid = "prometheus" expr = "sort_desc(sum(increase(jobs_processed_total{container_name='container'}[$__range])) by (job_type))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" ref_id = "Prometheus_Query" instant = true @@ -101,7 +101,7 @@ data "gdashboard_bar_gauge" "jobs_processed" { prometheus { uid = "prometheus" expr = "sort_desc(sum(increase(jobs_processed_total{container_name='container'}[$__range])) by (job_type))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" instant = true } @@ -115,7 +115,7 @@ data "gdashboard_bar_gauge" "mails_sent" { prometheus { uid = "prometheus" expr = "sort_desc(sum(increase(mails_sent_total{container_name='container'}[$__range])) by (mail_type))" - min_interval = "30" + min_step = "30" legend_format = "{{mail_type}}" instant = true } @@ -809,6 +809,7 @@ Optional: - `cloudwatch` (Block List) The CloudWatch query. (see [below for nested schema](#nestedblock--queries--cloudwatch)) - `expression` (Block List) The expression query. (see [below for nested schema](#nestedblock--queries--expression)) +- `min_interval` (String) The lower bounds on the interval between data points. - `prometheus` (Block List) The Prometheus query. (see [below for nested schema](#nestedblock--queries--prometheus)) @@ -863,7 +864,6 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `label` (String) The legend name. - `match_exact` (Boolean) If enabled you also need to specify **all** the dimensions of the metric you’re querying. -- `min_interval` (String) The lower bounds on the interval between data points. - `period` (String) The minimum interval between points in seconds. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. - `region` (String) The AWS region to query the metrics from. @@ -941,7 +941,7 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `instant` (Boolean) Whether to return the latest value from the time series or not. - `legend_format` (String) The legend name. -- `min_interval` (String) The lower bounds on the interval between data points. +- `min_step` (String) The lower bounds on the interval between data points. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. diff --git a/docs/data-sources/gauge.md b/docs/data-sources/gauge.md index e76b219..8ade329 100644 --- a/docs/data-sources/gauge.md +++ b/docs/data-sources/gauge.md @@ -79,7 +79,7 @@ data "gdashboard_gauge" "jvm_memory" { prometheus { uid = "prometheus" expr = "sum(increase(jvm_memory_total{container_name='container'}[$__rate_interval]))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" ref_id = "Prometheus_Query" instant = true @@ -139,7 +139,7 @@ data "gdashboard_gauge" "jvm_memory" { prometheus { uid = "prometheus" expr = "sum(increase(jvm_memory_total{container_name='container'}[$__rate_interval]))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" instant = true } @@ -153,7 +153,7 @@ data "gdashboard_gauge" "native_memory" { prometheus { uid = "prometheus" expr = "sum(increase(native_total{container_name='container'}[$__rate_interval]))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" instant = true } @@ -847,6 +847,7 @@ Optional: - `cloudwatch` (Block List) The CloudWatch query. (see [below for nested schema](#nestedblock--queries--cloudwatch)) - `expression` (Block List) The expression query. (see [below for nested schema](#nestedblock--queries--expression)) +- `min_interval` (String) The lower bounds on the interval between data points. - `prometheus` (Block List) The Prometheus query. (see [below for nested schema](#nestedblock--queries--prometheus)) @@ -901,7 +902,6 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `label` (String) The legend name. - `match_exact` (Boolean) If enabled you also need to specify **all** the dimensions of the metric you’re querying. -- `min_interval` (String) The lower bounds on the interval between data points. - `period` (String) The minimum interval between points in seconds. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. - `region` (String) The AWS region to query the metrics from. @@ -979,7 +979,7 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `instant` (Boolean) Whether to return the latest value from the time series or not. - `legend_format` (String) The legend name. -- `min_interval` (String) The lower bounds on the interval between data points. +- `min_step` (String) The lower bounds on the interval between data points. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. diff --git a/docs/data-sources/logs.md b/docs/data-sources/logs.md index 1376d63..338d5dd 100644 --- a/docs/data-sources/logs.md +++ b/docs/data-sources/logs.md @@ -95,6 +95,7 @@ Optional: - `cloudwatch` (Block List) The CloudWatch query. (see [below for nested schema](#nestedblock--queries--cloudwatch)) - `expression` (Block List) The expression query. (see [below for nested schema](#nestedblock--queries--expression)) +- `min_interval` (String) The lower bounds on the interval between data points. - `prometheus` (Block List) The Prometheus query. (see [below for nested schema](#nestedblock--queries--prometheus)) @@ -149,7 +150,6 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `label` (String) The legend name. - `match_exact` (Boolean) If enabled you also need to specify **all** the dimensions of the metric you’re querying. -- `min_interval` (String) The lower bounds on the interval between data points. - `period` (String) The minimum interval between points in seconds. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. - `region` (String) The AWS region to query the metrics from. @@ -227,5 +227,5 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `instant` (Boolean) Whether to return the latest value from the time series or not. - `legend_format` (String) The legend name. -- `min_interval` (String) The lower bounds on the interval between data points. +- `min_step` (String) The lower bounds on the interval between data points. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. diff --git a/docs/data-sources/stat.md b/docs/data-sources/stat.md index 80b190d..885b6c2 100644 --- a/docs/data-sources/stat.md +++ b/docs/data-sources/stat.md @@ -844,6 +844,7 @@ Optional: - `cloudwatch` (Block List) The CloudWatch query. (see [below for nested schema](#nestedblock--queries--cloudwatch)) - `expression` (Block List) The expression query. (see [below for nested schema](#nestedblock--queries--expression)) +- `min_interval` (String) The lower bounds on the interval between data points. - `prometheus` (Block List) The Prometheus query. (see [below for nested schema](#nestedblock--queries--prometheus)) @@ -898,7 +899,6 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `label` (String) The legend name. - `match_exact` (Boolean) If enabled you also need to specify **all** the dimensions of the metric you’re querying. -- `min_interval` (String) The lower bounds on the interval between data points. - `period` (String) The minimum interval between points in seconds. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. - `region` (String) The AWS region to query the metrics from. @@ -976,7 +976,7 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `instant` (Boolean) Whether to return the latest value from the time series or not. - `legend_format` (String) The legend name. -- `min_interval` (String) The lower bounds on the interval between data points. +- `min_step` (String) The lower bounds on the interval between data points. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. diff --git a/docs/data-sources/table.md b/docs/data-sources/table.md index 9cb9864..0838afa 100644 --- a/docs/data-sources/table.md +++ b/docs/data-sources/table.md @@ -879,6 +879,7 @@ Optional: - `cloudwatch` (Block List) The CloudWatch query. (see [below for nested schema](#nestedblock--queries--cloudwatch)) - `expression` (Block List) The expression query. (see [below for nested schema](#nestedblock--queries--expression)) +- `min_interval` (String) The lower bounds on the interval between data points. - `prometheus` (Block List) The Prometheus query. (see [below for nested schema](#nestedblock--queries--prometheus)) @@ -933,7 +934,6 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `label` (String) The legend name. - `match_exact` (Boolean) If enabled you also need to specify **all** the dimensions of the metric you’re querying. -- `min_interval` (String) The lower bounds on the interval between data points. - `period` (String) The minimum interval between points in seconds. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. - `region` (String) The AWS region to query the metrics from. @@ -1011,7 +1011,7 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `instant` (Boolean) Whether to return the latest value from the time series or not. - `legend_format` (String) The legend name. -- `min_interval` (String) The lower bounds on the interval between data points. +- `min_step` (String) The lower bounds on the interval between data points. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. diff --git a/docs/data-sources/timeseries.md b/docs/data-sources/timeseries.md index ab9aebc..8fc7b21 100644 --- a/docs/data-sources/timeseries.md +++ b/docs/data-sources/timeseries.md @@ -77,7 +77,7 @@ data "gdashboard_timeseries" "jvm_memory" { expr = "sum(increase(jvm_memory_total{container_name='container'}[$__rate_interval]))" instant = false ref_id = "Prometheus_Query" - min_interval = "30" + min_step = "30" legend_format = "Memory total" } } @@ -137,7 +137,7 @@ data "gdashboard_timeseries" "jvm_memory" { expr = "sum(increase(jvm_memory_total{container_name='container'}[$__rate_interval]))" instant = false ref_id = "Prometheus_Query" - min_interval = "30" + min_step = "30" legend_format = "Memory total" } } @@ -159,7 +159,7 @@ data "gdashboard_timeseries" "native_memory" { expr = "sum(increase(native_memory_total{container_name='container'}[$__rate_interval]))" instant = false ref_id = "Prometheus_Query" - min_interval = "30" + min_step = "30" legend_format = "Memory total" } } @@ -874,6 +874,7 @@ Optional: - `cloudwatch` (Block List) The CloudWatch query. (see [below for nested schema](#nestedblock--queries--cloudwatch)) - `expression` (Block List) The expression query. (see [below for nested schema](#nestedblock--queries--expression)) +- `min_interval` (String) The lower bounds on the interval between data points. - `prometheus` (Block List) The Prometheus query. (see [below for nested schema](#nestedblock--queries--prometheus)) @@ -928,7 +929,6 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `label` (String) The legend name. - `match_exact` (Boolean) If enabled you also need to specify **all** the dimensions of the metric you’re querying. -- `min_interval` (String) The lower bounds on the interval between data points. - `period` (String) The minimum interval between points in seconds. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. - `region` (String) The AWS region to query the metrics from. @@ -1006,7 +1006,7 @@ Optional: - `hide` (Boolean) Whether to hide query result from the panel or not. - `instant` (Boolean) Whether to return the latest value from the time series or not. - `legend_format` (String) The legend name. -- `min_interval` (String) The lower bounds on the interval between data points. +- `min_step` (String) The lower bounds on the interval between data points. - `ref_id` (String) The ID of the query. The ID can be used to reference queries in math expressions. diff --git a/examples/data-sources/gdashboard_bar_gauge/data-source-full.tf b/examples/data-sources/gdashboard_bar_gauge/data-source-full.tf index 6e39723..031f631 100644 --- a/examples/data-sources/gdashboard_bar_gauge/data-source-full.tf +++ b/examples/data-sources/gdashboard_bar_gauge/data-source-full.tf @@ -30,7 +30,7 @@ data "gdashboard_bar_gauge" "jobs_processed" { prometheus { uid = "prometheus" expr = "sort_desc(sum(increase(jobs_processed_total{container_name='container'}[$__range])) by (job_type))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" ref_id = "Prometheus_Query" instant = true diff --git a/examples/data-sources/gdashboard_bar_gauge/data-source-provider-defaults.tf b/examples/data-sources/gdashboard_bar_gauge/data-source-provider-defaults.tf index 090d2fc..84a0911 100644 --- a/examples/data-sources/gdashboard_bar_gauge/data-source-provider-defaults.tf +++ b/examples/data-sources/gdashboard_bar_gauge/data-source-provider-defaults.tf @@ -24,7 +24,7 @@ data "gdashboard_bar_gauge" "jobs_processed" { prometheus { uid = "prometheus" expr = "sort_desc(sum(increase(jobs_processed_total{container_name='container'}[$__range])) by (job_type))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" instant = true } @@ -38,7 +38,7 @@ data "gdashboard_bar_gauge" "mails_sent" { prometheus { uid = "prometheus" expr = "sort_desc(sum(increase(mails_sent_total{container_name='container'}[$__range])) by (mail_type))" - min_interval = "30" + min_step = "30" legend_format = "{{mail_type}}" instant = true } diff --git a/examples/data-sources/gdashboard_gauge/data-source-full.tf b/examples/data-sources/gdashboard_gauge/data-source-full.tf index 8c2a598..85cd166 100644 --- a/examples/data-sources/gdashboard_gauge/data-source-full.tf +++ b/examples/data-sources/gdashboard_gauge/data-source-full.tf @@ -49,7 +49,7 @@ data "gdashboard_gauge" "jvm_memory" { prometheus { uid = "prometheus" expr = "sum(increase(jvm_memory_total{container_name='container'}[$__rate_interval]))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" ref_id = "Prometheus_Query" instant = true diff --git a/examples/data-sources/gdashboard_gauge/data-source-provider-defaults.tf b/examples/data-sources/gdashboard_gauge/data-source-provider-defaults.tf index e4bb2c9..98b10a8 100644 --- a/examples/data-sources/gdashboard_gauge/data-source-provider-defaults.tf +++ b/examples/data-sources/gdashboard_gauge/data-source-provider-defaults.tf @@ -43,7 +43,7 @@ data "gdashboard_gauge" "jvm_memory" { prometheus { uid = "prometheus" expr = "sum(increase(jvm_memory_total{container_name='container'}[$__rate_interval]))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" instant = true } @@ -57,7 +57,7 @@ data "gdashboard_gauge" "native_memory" { prometheus { uid = "prometheus" expr = "sum(increase(native_total{container_name='container'}[$__rate_interval]))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" instant = true } diff --git a/examples/data-sources/gdashboard_timeseries/data-source-full.tf b/examples/data-sources/gdashboard_timeseries/data-source-full.tf index 83b3222..6000cc1 100644 --- a/examples/data-sources/gdashboard_timeseries/data-source-full.tf +++ b/examples/data-sources/gdashboard_timeseries/data-source-full.tf @@ -48,7 +48,7 @@ data "gdashboard_timeseries" "jvm_memory" { expr = "sum(increase(jvm_memory_total{container_name='container'}[$__rate_interval]))" instant = false ref_id = "Prometheus_Query" - min_interval = "30" + min_step = "30" legend_format = "Memory total" } } diff --git a/examples/data-sources/gdashboard_timeseries/data-source-provider-defaults.tf b/examples/data-sources/gdashboard_timeseries/data-source-provider-defaults.tf index 8570260..f82333e 100644 --- a/examples/data-sources/gdashboard_timeseries/data-source-provider-defaults.tf +++ b/examples/data-sources/gdashboard_timeseries/data-source-provider-defaults.tf @@ -44,7 +44,7 @@ data "gdashboard_timeseries" "jvm_memory" { expr = "sum(increase(jvm_memory_total{container_name='container'}[$__rate_interval]))" instant = false ref_id = "Prometheus_Query" - min_interval = "30" + min_step = "30" legend_format = "Memory total" } } @@ -66,7 +66,7 @@ data "gdashboard_timeseries" "native_memory" { expr = "sum(increase(native_memory_total{container_name='container'}[$__rate_interval]))" instant = false ref_id = "Prometheus_Query" - min_interval = "30" + min_step = "30" legend_format = "Memory total" } } diff --git a/internal/provider/bar_gauge_data_source.go b/internal/provider/bar_gauge_data_source.go index e84011b..2ce04f4 100644 --- a/internal/provider/bar_gauge_data_source.go +++ b/internal/provider/bar_gauge_data_source.go @@ -161,7 +161,7 @@ func (d *BarGaugeDataSource) Read(ctx context.Context, req datasource.ReadReques return } - targets := createTargets(data.Queries) + targets, minInterval := createTargets(data.Queries) fieldConfig := createFieldConfig(d.Defaults.Field, data.Field) transformations := createTransformations(data.Transformations) @@ -206,6 +206,7 @@ func (d *BarGaugeDataSource) Read(ctx context.Context, req datasource.ReadReques Span: 12, IsNew: true, Transformations: transformations, + Interval: minInterval, }, BarGaugePanel: &grafana.BarGaugePanel{ Targets: targets, diff --git a/internal/provider/bar_gauge_data_source_test.go b/internal/provider/bar_gauge_data_source_test.go index fbeaf4b..1fdd3ca 100644 --- a/internal/provider/bar_gauge_data_source_test.go +++ b/internal/provider/bar_gauge_data_source_test.go @@ -96,7 +96,7 @@ data "gdashboard_bar_gauge" "test" { prometheus { uid = "prometheus" expr = "sort_desc(sum(increase(data[$__range])) by (job_type))" - min_interval = "30" + min_step = "30" legend_format = "{{job_type}}" instant = true ref_id = "Prometheus_Query" diff --git a/internal/provider/gauge_data_source.go b/internal/provider/gauge_data_source.go index 9d8ef36..458753c 100644 --- a/internal/provider/gauge_data_source.go +++ b/internal/provider/gauge_data_source.go @@ -153,7 +153,7 @@ func (d *GaugeDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - targets := createTargets(data.Queries) + targets, minInterval := createTargets(data.Queries) fieldConfig := createFieldConfig(d.Defaults.Field, data.Field) transformations := createTransformations(data.Transformations) @@ -198,6 +198,7 @@ func (d *GaugeDataSource) Read(ctx context.Context, req datasource.ReadRequest, Span: 12, IsNew: true, Transformations: transformations, + Interval: minInterval, }, GaugePanel: &grafana.GaugePanel{ Targets: targets, diff --git a/internal/provider/gauge_data_source_test.go b/internal/provider/gauge_data_source_test.go index 5d0d779..efb0f76 100644 --- a/internal/provider/gauge_data_source_test.go +++ b/internal/provider/gauge_data_source_test.go @@ -89,10 +89,10 @@ data "gdashboard_gauge" "test" { queries { prometheus { - uid = "prometheus" - expr = "sum (jvm_memory_bytes_used{container_name='container', area='heap'}) / sum (jvm_memory_bytes_max{container_name='container', area='heap'}) * 100" - min_interval = "30" - instant = true + uid = "prometheus" + expr = "sum (jvm_memory_bytes_used{container_name='container', area='heap'}) / sum (jvm_memory_bytes_max{container_name='container', area='heap'}) * 100" + min_step = "30" + instant = true } } } diff --git a/internal/provider/grafana/panel.go b/internal/provider/grafana/panel.go index eb9697a..f786144 100644 --- a/internal/provider/grafana/panel.go +++ b/internal/provider/grafana/panel.go @@ -84,6 +84,7 @@ type ( Type string `json:"type"` Alert *Alert `json:"alert,omitempty"` Transformations []Transformation `json:"transformations,omitempty"` + Interval *string `json:"interval,omitempty"` } AlertEvaluator struct { Params []float64 `json:"params,omitempty"` diff --git a/internal/provider/logs_data_source.go b/internal/provider/logs_data_source.go index 418eb45..505d33d 100644 --- a/internal/provider/logs_data_source.go +++ b/internal/provider/logs_data_source.go @@ -151,7 +151,7 @@ func (d *LogsDataSource) Read(ctx context.Context, req datasource.ReadRequest, r return } - targets := createTargets(data.Queries) + targets, minInterval := createTargets(data.Queries) falseVal := false trueVal := true @@ -210,11 +210,12 @@ func (d *LogsDataSource) Read(ctx context.Context, req datasource.ReadRequest, r panel := &grafana.Panel{ CommonPanel: grafana.CommonPanel{ - OfType: grafana.LogsType, - Title: data.Title.ValueString(), - Type: "logs", - Span: 12, - IsNew: true, + OfType: grafana.LogsType, + Title: data.Title.ValueString(), + Type: "logs", + Span: 12, + IsNew: true, + Interval: minInterval, }, LogsPanel: &grafana.LogsPanel{ Targets: targets, diff --git a/internal/provider/stat_data_source.go b/internal/provider/stat_data_source.go index bb88e07..7d26ae3 100644 --- a/internal/provider/stat_data_source.go +++ b/internal/provider/stat_data_source.go @@ -181,7 +181,7 @@ func (d *StatDataSource) Read(ctx context.Context, req datasource.ReadRequest, r return } - targets := createTargets(data.Queries) + targets, minInterval := createTargets(data.Queries) fieldConfig := createFieldConfig(d.Defaults.Field, data.Field) transformations := createTransformations(data.Transformations) @@ -236,6 +236,7 @@ func (d *StatDataSource) Read(ctx context.Context, req datasource.ReadRequest, r Span: 12, IsNew: true, Transformations: transformations, + Interval: minInterval, }, StatPanel: &grafana.StatPanel{ Targets: targets, diff --git a/internal/provider/table_data_source.go b/internal/provider/table_data_source.go index 4f2e536..f77a50f 100644 --- a/internal/provider/table_data_source.go +++ b/internal/provider/table_data_source.go @@ -251,7 +251,7 @@ func (d *TableDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - targets := createTargets(data.Queries) + targets, minInterval := createTargets(data.Queries) fieldConfig := createFieldConfig(d.Defaults.Field, data.Field) transformations := createTransformations(data.Transformations) @@ -339,6 +339,7 @@ func (d *TableDataSource) Read(ctx context.Context, req datasource.ReadRequest, Span: 12, IsNew: true, Transformations: transformations, + Interval: minInterval, }, TablePanel: &grafana.TablePanel{ Targets: targets, diff --git a/internal/provider/timeseries_data_source.go b/internal/provider/timeseries_data_source.go index 536e2d3..80e86db 100644 --- a/internal/provider/timeseries_data_source.go +++ b/internal/provider/timeseries_data_source.go @@ -304,7 +304,7 @@ func (d *TimeseriesDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - targets := createTargets(data.Queries) + targets, minInterval := createTargets(data.Queries) transformations := createTransformations(data.Transformations) legendOptions := grafana.TimeseriesLegendOptions{ @@ -451,6 +451,7 @@ func (d *TimeseriesDataSource) Read(ctx context.Context, req datasource.ReadRequ Span: 12, IsNew: true, Transformations: transformations, + Interval: minInterval, }, TimeseriesPanel: &grafana.TimeseriesPanel{ Targets: targets, diff --git a/internal/provider/timeseries_data_source_test.go b/internal/provider/timeseries_data_source_test.go index 08b28e8..baaec86 100644 --- a/internal/provider/timeseries_data_source_test.go +++ b/internal/provider/timeseries_data_source_test.go @@ -81,7 +81,7 @@ data "gdashboard_timeseries" "test" { expr = "sum(increase(jvm_memory_total{container_name='container'}[$__rate_interval]))" instant = false ref_id = "Prometheus_Query" - min_interval = "30" + min_step = "30" legend_format = "Memory total" } diff --git a/internal/provider/utils.go b/internal/provider/utils.go index 0bdc25e..7e00c35 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -260,8 +260,9 @@ type ByQueryIDOverrideOptions struct { } type Query struct { - Prometheus []PrometheusTarget `tfsdk:"prometheus"` - CloudWatch []CloudWatchTarget `tfsdk:"cloudwatch"` + MinInterval types.String `tfsdk:"min_interval"` + Prometheus []PrometheusTarget `tfsdk:"prometheus"` + CloudWatch []CloudWatchTarget `tfsdk:"cloudwatch"` Expression []ExpressionTarget `tfsdk:"expression"` } @@ -273,7 +274,7 @@ type PrometheusTarget struct { Format types.String `tfsdk:"format"` // etc RefId types.String `tfsdk:"ref_id"` - MinInterval types.String `tfsdk:"min_interval"` + MinStep types.String `tfsdk:"min_step"` LegendFormat types.String `tfsdk:"legend_format"` } @@ -292,10 +293,9 @@ type CloudWatchMetricsTarget struct { MatchExact types.Bool `tfsdk:"match_exact"` Region types.String `tfsdk:"region"` // etc - RefId types.String `tfsdk:"ref_id"` - MinInterval types.String `tfsdk:"min_interval"` - Period types.String `tfsdk:"period"` - Label types.String `tfsdk:"label"` + RefId types.String `tfsdk:"ref_id"` + Period types.String `tfsdk:"period"` + Label types.String `tfsdk:"label"` } type CloudWatchLogGroup struct { @@ -672,7 +672,7 @@ func queryBlock() schema.Block { stringvalidator.OneOf("time_series", "table", "heatmap"), }, }, - "min_interval": schema.StringAttribute{ + "min_step": schema.StringAttribute{ Optional: true, Description: "The lower bounds on the interval between data points.", }, @@ -748,10 +748,6 @@ func queryBlock() schema.Block { Optional: true, Description: "The ID of the query. The ID can be used to reference queries in math expressions.", }, - "min_interval": schema.StringAttribute{ - Optional: true, - Description: "The lower bounds on the interval between data points.", - }, "period": schema.StringAttribute{ Optional: true, Description: "The minimum interval between points in seconds.", @@ -951,6 +947,12 @@ func queryBlock() schema.Block { }, }, }, + Attributes: map[string]schema.Attribute{ + "min_interval": schema.StringAttribute{ + Optional: true, + Description: "The lower bounds on the interval between data points.", + }, + }, }, Validators: []validator.List{ listvalidator.SizeAtMost(3), @@ -1185,10 +1187,13 @@ func descriptionAttribute() schema.StringAttribute { // creators -func createTargets(queries []Query) []grafana.Target { +func createTargets(queries []Query) ([]grafana.Target, *string) { targets := make([]grafana.Target, 0) + var minInterval *string for _, group := range queries { + minInterval = group.MinInterval.ValueStringPointer() + for _, target := range group.Prometheus { t := grafana.Target{ Datasource: grafana.Datasource{ @@ -1198,7 +1203,7 @@ func createTargets(queries []Query) []grafana.Target { RefID: target.RefId.ValueString(), Hide: target.Hide.ValueBool(), Expr: target.Expr.ValueString(), - Interval: target.MinInterval.ValueString(), + Interval: target.MinStep.ValueString(), LegendFormat: target.LegendFormat.ValueString(), Instant: target.Instant.ValueBool(), Format: target.Format.ValueString(), @@ -1224,7 +1229,6 @@ func createTargets(queries []Query) []grafana.Target { }, RefID: metrics.RefId.ValueString(), Hide: metrics.Hide.ValueBool(), - Interval: metrics.MinInterval.ValueString(), QueryMode: "Metrics", MetricQueryType: &zero, MetricEditorMode: &zero, @@ -1316,7 +1320,7 @@ func createTargets(queries []Query) []grafana.Target { } } - return targets + return targets, minInterval } type ValueMappingResult struct {