suspect Grafana transformations could play a role
It is indeed possible with transformations.
In short
- Set query format to
table
- Add transformation
Grouping to matrix
.
- Set column to
band
- Set row to
time
- Set cell_value to
state
- Add transformation
Convert field type
- Set field to
Time/<column>
- As
Time
- Configure
Value mappings
for each of the states you have
Explanation
I'll show how the transformations work
To see what is happening in the transformations, it is always helpful to enable the as this will show actual returned data to the visualization.
Also toggling the transformations on and off using the next to transformation really helps in seeing what is happening.
The state timeline visualization works best with a table as data source.
Although it does support time series, the information we want to show is not a time series.
The visualization works best when the data is as follows.
π Time |
π¦ Band 1 |
π¦ Band 2 |
T1 |
State A |
State B |
T2 |
State C |
State A |
But when data is formatted as a time series the data will look like this:
π Time |
πͺ {Band 1, State A} |
πͺ {Band 1, State C} |
πͺ ... |
T1 |
1 |
|
|
T2 |
|
1 |
|
So first we need to set query format to from Timeseries
to Table
.
Expend the query options, and set format to Table.
When doing that our table will look like this.
π Time |
π¦ band |
π¦ state |
πͺ Value |
T1 |
Band 1 |
State A |
1 |
T1 |
Band 2 |
State B |
1 |
T2 |
Band 1 |
State C |
1 |
T2 |
Band 1 |
State A |
1 |
Next step is to pivot the table. For this we add the Grouping to matrix
transformation.
- Set column to
band
- Set row to
time
- Set cell_value to
state
π¦ Time |
π¦ Band 1 |
π¦ Band 2 |
1000 |
State A |
State B |
2000 |
State C |
State A |
Now there is just one problem left. The first column should be of data type time
but it is of type string
. You can see this by the icon infront of the column name. Indicated with emoji in my examples.
But this is an easy fix. Just add Convert field type
transformation below Grouping to matrix
transformation.
- Set field to
Time/<column>
- As
Time
Now the table should look as follows:
π Time |
π¦ Band 1 |
π¦ Band 2 |
T1 |
State A |
State B |
T2 |
State C |
State A |
Example
Following shows an example for ArgoCD.
It shows the sync status for each application over time.
The prometheus exported data from ArgoCD looks as follows:
argocd_app_info{name="Application A", sync_state="Synced", ...} 1
argocd_app_info{name="Application B", sync_state="OufOfSync", ...} 1
argocd_app_info{name="Application C", sync_state="Unknown", ...} 1
argocd_app_info{name="Application D", sync_state="Synced", ...} 1