Skip to content

Commit

Permalink
Rename prometheus#min_interval -> prometheus#min_step. Add `query…
Browse files Browse the repository at this point in the history
…#min_interval`
  • Loading branch information
iRevive committed Mar 26, 2024
1 parent 678de42 commit 7a15c0f
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 63 deletions.
10 changes: 5 additions & 5 deletions docs/data-sources/bar_gauge.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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))

<a id="nestedblock--queries--cloudwatch"></a>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.


Expand Down
10 changes: 5 additions & 5 deletions docs/data-sources/gauge.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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))

<a id="nestedblock--queries--cloudwatch"></a>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.


Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

<a id="nestedblock--queries--cloudwatch"></a>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
4 changes: 2 additions & 2 deletions docs/data-sources/stat.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

<a id="nestedblock--queries--cloudwatch"></a>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.


Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

<a id="nestedblock--queries--cloudwatch"></a>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.


Expand Down
10 changes: 5 additions & 5 deletions docs/data-sources/timeseries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down Expand Up @@ -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))

<a id="nestedblock--queries--cloudwatch"></a>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion examples/data-sources/gdashboard_gauge/data-source-full.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/bar_gauge_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/bar_gauge_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/gauge_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/gauge_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
1 change: 1 addition & 0 deletions internal/provider/grafana/panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Loading

0 comments on commit 7a15c0f

Please sign in to comment.