You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-guide/dashboards/custom-charts/custom-charts-for-metrics-using-promql.md
+35-42Lines changed: 35 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,16 @@
1
-
2
1
This guide explains how to build custom charts for metrics in OpenObserve using PromQL. The goal is to help new and advanced users understand how raw metrics data transforms into a fully rendered chart through predictable and repeatable steps.
3
2
4
3
## How metric data flows into a chart
5
-
Metrics data in OpenObserve follows a fixed transformation pipeline:
4
+
Metrics data in OpenObserve follows a fixed transformation flow:
6
5
7
6
`Metrics data in OpenObserve > PromQL query > Matrix JSON > Transform into timestamp-value pairs > Render chart`
8
7
9
-
This data pipeline never changes. Only two things vary:
8
+
This data flow never changes. Only two things vary:
10
9
11
10
- The **PromQL query**
12
11
- The **JavaScript transformation logic** that prepares data based on the chart you want to build
13
12
14
-
The example uses the `container_cpu_time metric` and builds a time-series line chart.
15
-
13
+
The example uses the `container_cpu_time` metric and builds a time-series line chart.
16
14
17
15
## How to build the custom chart for metrics using PromQL
18
16
@@ -121,15 +119,11 @@ The example uses the `container_cpu_time metric` and builds a time-series line c
121
119
metric: { ...labels... },
122
120
values: [
123
121
[timestamp, value],
124
-
125
-
...
122
+
...
126
123
]
127
-
}
128
-
124
+
}
129
125
]
130
-
131
126
}
132
-
133
127
]
134
128
```
135
129
Here,
@@ -148,7 +142,7 @@ The example uses the `container_cpu_time metric` and builds a time-series line c
148
142
??? "Step 5: Understand how to transform the data and render the chart"
149
143
### Step 5: Understand how to transform the data and render the chart
150
144
Now that you have inspected the raw PromQL response, you can prepare the data and build a chart.
151
-
Every PromQL-based custom chart in OpenObserve follows the same pipeline:
145
+
Every PromQL-based custom chart in OpenObserve follows the same flow:
152
146
`data > transform > series > option > chart`
153
147
The following subsections explain each part in the correct order.
154
148
@@ -179,7 +173,7 @@ The example uses the `container_cpu_time metric` and builds a time-series line c
179
173
Here:
180
174
181
175
- Each object inside result represents one metric series.
182
-
- The metric object holds all identifying labels.
176
+
- The `metric` object holds all identifying labels.
183
177
- The values array holds the actual time-series data as `[timestamp, value]`.
184
178
185
179
@@ -255,52 +249,51 @@ The example uses the `container_cpu_time metric` and builds a time-series line c
255
249
**JavaScript code:**
256
250
257
251
```js linenums="1"
252
+
/// Set the chart type you want
253
+
// Supported examples: "line", "scatter", "bar"
254
+
const chartType = "bar";
255
+
258
256
// Step 1: prepare an empty list of series
259
257
const series = [];
260
258
261
259
// Step 2: read the PromQL response from OpenObserve
262
260
if (Array.isArray(data) && data.length > 0) {
263
261
const query = data[0];
264
-
if (query.result && Array.isArray(query.result)) {
265
-
for (const item of query.result) {
266
-
if (!Array.isArray(item.values)) {
267
-
continue;
268
-
}
269
262
270
-
// Step 3: convert [timestamp, value] to [ISO time, number]
Copy file name to clipboardExpand all lines: docs/user-guide/streams/schema-settings.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,10 +22,10 @@ For example:
22
22
-`58.0` as `Float64`
23
23
-`"58%"` as `Utf8`
24
24
25
-
## Index Type
25
+
## Index type
26
26
You can modify or assign an index type to a field to improve search performance. Indexing can reduce the amount of data that must be scanned during queries.
27
27
28
-
To learn more, visit the [Fields and Index in Streams](streams/fields-and-index-in-streams) page.
28
+
To learn more, visit the [Fields and Index in Streams](https://openobserve.ai/docs/user-guide/streams/data-type-and-index-type-in-streams/) page.
29
29
30
30
!!! Warning
31
31
Changing the index after storing data may lead to inconsistent query results or data retrieval failures.
0 commit comments