Skip to content

Commit

Permalink
Merge pull request #103 from gdashboard/threshold-style
Browse files Browse the repository at this point in the history
Support thresholds style
  • Loading branch information
iRevive authored Feb 22, 2024
2 parents 0c7cfc0 + 816c656 commit c87d9d1
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 26 deletions.
5 changes: 5 additions & 0 deletions docs/data-sources/bar_gauge.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--field--thresholds--step))

<a id="nestedblock--field--thresholds--step"></a>
Expand Down Expand Up @@ -407,6 +408,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_name--field--thresholds--step))

<a id="nestedblock--overrides--by_name--field--thresholds--step"></a>
Expand Down Expand Up @@ -531,6 +533,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_query_id--field--thresholds--step))

<a id="nestedblock--overrides--by_query_id--field--thresholds--step"></a>
Expand Down Expand Up @@ -655,6 +658,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_regex--field--thresholds--step))

<a id="nestedblock--overrides--by_regex--field--thresholds--step"></a>
Expand Down Expand Up @@ -779,6 +783,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_type--field--thresholds--step))

<a id="nestedblock--overrides--by_type--field--thresholds--step"></a>
Expand Down
5 changes: 5 additions & 0 deletions docs/data-sources/gauge.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--field--thresholds--step))

<a id="nestedblock--field--thresholds--step"></a>
Expand Down Expand Up @@ -445,6 +446,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_name--field--thresholds--step))

<a id="nestedblock--overrides--by_name--field--thresholds--step"></a>
Expand Down Expand Up @@ -569,6 +571,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_query_id--field--thresholds--step))

<a id="nestedblock--overrides--by_query_id--field--thresholds--step"></a>
Expand Down Expand Up @@ -693,6 +696,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_regex--field--thresholds--step))

<a id="nestedblock--overrides--by_regex--field--thresholds--step"></a>
Expand Down Expand Up @@ -817,6 +821,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_type--field--thresholds--step))

<a id="nestedblock--overrides--by_type--field--thresholds--step"></a>
Expand Down
5 changes: 5 additions & 0 deletions docs/data-sources/stat.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--field--thresholds--step))

<a id="nestedblock--field--thresholds--step"></a>
Expand Down Expand Up @@ -442,6 +443,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_name--field--thresholds--step))

<a id="nestedblock--overrides--by_name--field--thresholds--step"></a>
Expand Down Expand Up @@ -566,6 +568,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_query_id--field--thresholds--step))

<a id="nestedblock--overrides--by_query_id--field--thresholds--step"></a>
Expand Down Expand Up @@ -690,6 +693,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_regex--field--thresholds--step))

<a id="nestedblock--overrides--by_regex--field--thresholds--step"></a>
Expand Down Expand Up @@ -814,6 +818,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_type--field--thresholds--step))

<a id="nestedblock--overrides--by_type--field--thresholds--step"></a>
Expand Down
5 changes: 5 additions & 0 deletions docs/data-sources/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--field--thresholds--step))

<a id="nestedblock--field--thresholds--step"></a>
Expand Down Expand Up @@ -477,6 +478,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_name--field--thresholds--step))

<a id="nestedblock--overrides--by_name--field--thresholds--step"></a>
Expand Down Expand Up @@ -601,6 +603,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_query_id--field--thresholds--step))

<a id="nestedblock--overrides--by_query_id--field--thresholds--step"></a>
Expand Down Expand Up @@ -725,6 +728,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_regex--field--thresholds--step))

<a id="nestedblock--overrides--by_regex--field--thresholds--step"></a>
Expand Down Expand Up @@ -849,6 +853,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_type--field--thresholds--step))

<a id="nestedblock--overrides--by_type--field--thresholds--step"></a>
Expand Down
5 changes: 5 additions & 0 deletions docs/data-sources/timeseries.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) How the thresholds must be shown. The choices are: `line`, `dashed`, `area`, `line+area`, `dashed+area`.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--field--thresholds--step))

<a id="nestedblock--field--thresholds--step"></a>
Expand Down Expand Up @@ -472,6 +473,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) How the thresholds must be shown. The choices are: `line`, `dashed`, `area`, `line+area`, `dashed+area`.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_name--field--thresholds--step))

<a id="nestedblock--overrides--by_name--field--thresholds--step"></a>
Expand Down Expand Up @@ -596,6 +598,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) How the thresholds must be shown. The choices are: `line`, `dashed`, `area`, `line+area`, `dashed+area`.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_query_id--field--thresholds--step))

<a id="nestedblock--overrides--by_query_id--field--thresholds--step"></a>
Expand Down Expand Up @@ -720,6 +723,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) How the thresholds must be shown. The choices are: `line`, `dashed`, `area`, `line+area`, `dashed+area`.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_regex--field--thresholds--step))

<a id="nestedblock--overrides--by_regex--field--thresholds--step"></a>
Expand Down Expand Up @@ -844,6 +848,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) How the thresholds must be shown. The choices are: `line`, `dashed`, `area`, `line+area`, `dashed+area`.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--overrides--by_type--field--thresholds--step))

<a id="nestedblock--overrides--by_type--field--thresholds--step"></a>
Expand Down
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--defaults--bar_gauge--field--thresholds--step))

<a id="nestedblock--defaults--bar_gauge--field--thresholds--step"></a>
Expand Down Expand Up @@ -414,6 +415,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--defaults--gauge--field--thresholds--step))

<a id="nestedblock--defaults--gauge--field--thresholds--step"></a>
Expand Down Expand Up @@ -567,6 +569,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--defaults--stat--field--thresholds--step))

<a id="nestedblock--defaults--stat--field--thresholds--step"></a>
Expand Down Expand Up @@ -721,6 +724,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) Unused by this panel type. Ignore, please.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--defaults--table--field--thresholds--step))

<a id="nestedblock--defaults--table--field--thresholds--step"></a>
Expand Down Expand Up @@ -869,6 +873,7 @@ Optional:
- `mode` (String) The threshold mode. The choices are:
1) `absolute` - defined based on a number; for example, 80 on a scale of 1 to 150.
2) `percentage` - defined relative to minimum or maximum; for example, 80 percent.
- `show_as` (String) How the thresholds must be shown. The choices are: `line`, `dashed`, `area`, `line+area`, `dashed+area`.
- `step` (Block List) The threshold steps. (see [below for nested schema](#nestedblock--defaults--timeseries--field--thresholds--step))

<a id="nestedblock--defaults--timeseries--field--thresholds--step"></a>
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/bar_gauge_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ func (d *BarGaugeDataSource) Schema(ctx context.Context, req datasource.SchemaRe

Blocks: map[string]schema.Block{
"queries": queryBlock(),
"field": fieldBlock(),
"field": fieldBlock(false),
"graph": barGaugeGraphBlock(),
"overrides": fieldOverrideBlock(),
"overrides": fieldOverrideBlock(false),
"transform": transformationsBlock(),
},

Expand Down
4 changes: 2 additions & 2 deletions internal/provider/gauge_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ func (d *GaugeDataSource) Schema(ctx context.Context, req datasource.SchemaReque

Blocks: map[string]schema.Block{
"queries": queryBlock(),
"field": fieldBlock(),
"field": fieldBlock(false),
"graph": gaugeGraphBlock(),
"overrides": fieldOverrideBlock(),
"overrides": fieldOverrideBlock(false),
"transform": transformationsBlock(),
},

Expand Down
14 changes: 9 additions & 5 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (p *GrafanaDashboardBuilderProvider) Schema(ctx context.Context, req provid
Blocks: map[string]schema.Block{
"legend": timeseriesLegendBlock(),
"tooltip": timeseriesTooltipBlock(),
"field": fieldBlock(),
"field": fieldBlock(true),
"axis": axisBlock(),
"graph": timeseriesGraphBlock(),
},
Expand All @@ -137,7 +137,7 @@ func (p *GrafanaDashboardBuilderProvider) Schema(ctx context.Context, req provid
Description: "Bar gauge defaults.",
NestedObject: schema.NestedBlockObject{
Blocks: map[string]schema.Block{
"field": fieldBlock(),
"field": fieldBlock(false),
"graph": barGaugeGraphBlock(),
},
},
Expand All @@ -149,7 +149,7 @@ func (p *GrafanaDashboardBuilderProvider) Schema(ctx context.Context, req provid
Description: "Stat defaults.",
NestedObject: schema.NestedBlockObject{
Blocks: map[string]schema.Block{
"field": fieldBlock(),
"field": fieldBlock(false),
"graph": statGraphBlock(),
},
},
Expand All @@ -161,7 +161,7 @@ func (p *GrafanaDashboardBuilderProvider) Schema(ctx context.Context, req provid
Description: "Gauge defaults.",
NestedObject: schema.NestedBlockObject{
Blocks: map[string]schema.Block{
"field": fieldBlock(),
"field": fieldBlock(false),
"graph": gaugeGraphBlock(),
},
},
Expand All @@ -173,7 +173,7 @@ func (p *GrafanaDashboardBuilderProvider) Schema(ctx context.Context, req provid
Description: "Table defaults.",
NestedObject: schema.NestedBlockObject{
Blocks: map[string]schema.Block{
"field": fieldBlock(),
"field": fieldBlock(false),
},
},
Validators: []validator.List{
Expand Down Expand Up @@ -515,6 +515,10 @@ func updateFieldDefaults(defaults *FieldDefaults, opts []FieldOptions) {
defaults.Thresholds.Mode = threshold.Mode.ValueString()
}

if !threshold.ShowAs.IsNull() {
defaults.Thresholds.ShowAs = threshold.ShowAs.ValueString()
}

for i, step := range threshold.Steps {
s := ThresholdStepDefaults{
Color: step.Color.ValueString(),
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/stat_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ func (d *StatDataSource) Schema(ctx context.Context, req datasource.SchemaReques

Blocks: map[string]schema.Block{
"queries": queryBlock(),
"field": fieldBlock(),
"field": fieldBlock(false),
"graph": statGraphBlock(),
"overrides": fieldOverrideBlock(),
"overrides": fieldOverrideBlock(false),
"transform": transformationsBlock(),
},

Expand Down
4 changes: 2 additions & 2 deletions internal/provider/table_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ func (d *TableDataSource) Schema(ctx context.Context, req datasource.SchemaReque

Blocks: map[string]schema.Block{
"queries": queryBlock(),
"field": fieldBlock(),
"field": fieldBlock(false),
"graph": tableGraphBlock(),
"overrides": fieldOverrideBlock(),
"overrides": fieldOverrideBlock(false),
"transform": transformationsBlock(),
},

Expand Down
Loading

0 comments on commit c87d9d1

Please sign in to comment.