Skip to content

Commit c75ecc9

Browse files
authored
Simplify custom dashboard JSON in example (#53)
1 parent 7d0117d commit c75ecc9

File tree

1 file changed

+19
-101
lines changed

1 file changed

+19
-101
lines changed

examples/advanced/main.tf

Lines changed: 19 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -88,139 +88,57 @@ resource "logtail_dashboard" "custom" {
8888
preset = {
8989
preset_type = "implicit"
9090
preset_variables = [
91-
{
92-
name = "source"
93-
variable_type = "source"
94-
values = []
95-
default_values = null
96-
sql_definition = null
97-
},
9891
{
9992
name = "level"
10093
variable_type = "select_with_sql"
10194
values = []
10295
default_values = null
10396
sql_definition = "level"
10497
},
105-
{
106-
name = "start_time"
107-
variable_type = "datetime"
108-
values = ["now-3h"]
109-
default_values = null
110-
sql_definition = null
111-
},
112-
{
113-
name = "end_time"
114-
variable_type = "datetime"
115-
values = ["now"]
116-
default_values = null
117-
sql_definition = null
118-
},
11998
]
12099
}
121100
charts = [
122101
{
123-
chart_type = "line_chart"
124-
name = "Number of logs"
125-
description = null
126-
x = 0
127-
y = 0
128-
w = 9
129-
h = 8
130-
transform_with = "// Transform chart data before rendering.\n// Following function is called when new data arrives, and again with `completed = true` after all data arrives.\n// You can transform the data here arbitrarily.\n// Most chart types expect columns 'time', 'value' and optionally 'series' by default.\nasync (existingDataByQuery, newDataByQuery, completed) => {\n return Object.keys(newDataByQuery).reduce((result, queryIndex) => {\n result[queryIndex] = result[queryIndex].concat(newDataByQuery[queryIndex]);\n return result;\n }, existingDataByQuery);\n}\n"
102+
chart_type = "line_chart"
103+
name = "Number of logs"
104+
x = 0
105+
y = 0
106+
w = 9
107+
h = 8
131108
settings = {
132-
unit = "shortened"
133-
label = "shown_below"
134-
legend = "shown_below"
135-
stacking = "dont_stack"
136-
lat_column = "latitude"
137-
lng_column = "longitude"
138-
time_column = "time"
139-
x_axis_type = "time"
140-
y_axis_scale = "linear"
109+
unit = "shortened"
110+
label = "shown_below"
111+
legend = "shown_below"
112+
stacking = "dont_stack"
113+
time_column = "time"
141114
series_colors = {
142115
value = "#009fe3"
143116
}
144117
series_column = "series"
145118
value_columns = ["value"]
146119
decimal_places = 2
147-
point_size_column = "size"
148120
treat_missing_values = "connected"
149-
guessed_series_colors = {
150-
value = "#009fe3"
151-
}
152121
}
153122
chart_queries = [
154123
{
155-
name = null
156124
query_type = "sql_expression"
157125
sql_query = "SELECT {{time}} as time, countMerge(events_count) as value\nFROM {{source}}\nWHERE time BETWEEN {{start_time}} AND {{end_time}}\n [[ AND level = {{level}} ]]\nGROUP BY time\n"
158-
where_condition = null
159-
static_text = null
160-
y_axis = [
161-
{
162-
type = "integer"
163-
value = "events"
164-
measure = "count"
165-
}
166-
]
167-
filters = []
168-
group_by = []
169126
source_variable = "source"
170127
}
171128
]
172129
chart_alerts = []
173130
},
174131
{
175-
chart_type = "static_text_chart"
176-
name = "Static text"
177-
description = null
178-
x = 9
179-
y = 0
180-
w = 3
181-
h = 8
182-
transform_with = "// Transform chart data before rendering.\n// Following function is called when new data arrives, and again with `completed = true` after all data arrives.\n// You can transform the data here arbitrarily.\n// Most chart types expect columns 'time', 'value' and optionally 'series' by default.\nasync (existingDataByQuery, newDataByQuery, completed) => {\n return Object.keys(newDataByQuery).reduce((result, queryIndex) => {\n result[queryIndex] = result[queryIndex].concat(newDataByQuery[queryIndex]);\n return result;\n }, existingDataByQuery);\n}\n"
183-
settings = {
184-
unit = "shortened"
185-
fresh = true
186-
label = "shown_below"
187-
legend = "shown_below"
188-
stacking = "dont_stack"
189-
lat_column = "latitude"
190-
lng_column = "longitude"
191-
time_column = "time"
192-
x_axis_type = "time"
193-
y_axis_scale = "linear"
194-
series_colors = {
195-
value = "#009fe3"
196-
}
197-
series_column = "series"
198-
value_columns = ["value"]
199-
decimal_places = 2
200-
point_size_column = "size"
201-
treat_missing_values = "connected"
202-
guessed_series_colors = {
203-
value = "#009fe3"
204-
}
205-
}
132+
chart_type = "static_text_chart"
133+
name = "Static text"
134+
x = 9
135+
y = 0
136+
w = 3
137+
h = 8
206138
chart_queries = [
207139
{
208-
name = null
209-
query_type = "static_text"
210-
sql_query = null
211-
where_condition = null
212-
static_text = "## Imported from Terraform\n\nThis is an example custom dashboard."
213-
y_axis = [
214-
{
215-
name = "events"
216-
type = "integer"
217-
value = "events"
218-
measure = "count"
219-
}
220-
]
221-
filters = []
222-
group_by = []
223-
source_variable = null
140+
query_type = "static_text"
141+
static_text = "## Imported from Terraform\n\nThis is an example custom dashboard."
224142
}
225143
]
226144
chart_alerts = []

0 commit comments

Comments
 (0)