@@ -11,8 +11,10 @@ annotations, and dashboard variables.
1111 object at that path is an array it will be iterated over, with each object added
1212 as a row in the data frame, otherwise the result object will be the only row.
1313 - Can be separated by commas to use multiple data paths
14- - Timeseries data requires a field named ` Time ` containing the timestamp in a
15- format that can be parsed by ` moment() ` (e.g. ISO8601).
14+ - Timeseries data must include a timestamp field under the data path, default
15+ ` Time ` , in [ ISO8601] ( https://momentjs.com/docs/#/parsing/string/ ) or a
16+ configurable [ custom
17+ format] ( https://momentjs.com/docs/#/parsing/string-format/ ) .
1618- Nested types will be flattened into dot-delimited fields.
1719- Grafana variables should be substituted directly in the query (instead of
1820 using GraphQL variables). The dashboard time ranges are available in the
@@ -33,100 +35,108 @@ annotations, and dashboard variables.
3335
3436# Examples
3537
36- Below are some example queries demonstrating how to use the plugin. See the
37- [ project wiki] ( https://github.com/fifemon/graphql-datasource/wiki ) for further
38- examples and tutorials.
38+ Below are some example queries demonstrating how to use the plugin, using the
39+ [ FIFEMon GraphQL test source
40+ server] ( https://github.com/fifemon/graphql-test-source/ ) , which also includes a
41+ [ dashboard] ( https://raw.githubusercontent.com/fifemon/graphql-test-source/master/doc/graphql-test-dashboard.json )
42+ demonstrating these queries.
3943
4044## Basic timeseries
4145
4246``` graphql
4347query {
44- submissions (user : " $user" , from : " $__from" , to : " $__to" ) {
45- Time : submitTime
46- idle
47- running
48- completed
48+ data : simple_series (from : " ${__from:date:iso}" , to : " ${__to:date:iso}" , interval_ms : $__interval_ms ) {
49+ Time : timestamp
50+ value
4951 }
5052}
5153```
5254
53- - Data path: ` submissions `
54-
5555Note the use of the global ` $__from ` and ` $__to ` variables to insert the
56- dashboard time range into the query, alongside a dashboard variable ` $user ` .
56+ dashboard time range into the query and the use of ` $__interval_ms ` to specify
57+ the appropriate time interval for the graph.
58+
59+ ## Custom time format
60+
61+ ``` graphql
62+ query {
63+ simple_series (
64+ from : " ${__from:date:iso}"
65+ to : " ${__to:date:iso}"
66+ interval_ms : $__interval_ms
67+ format : " MM.dd.uuuu HHmmss"
68+ ) {
69+ timestamp
70+ value
71+ }
72+ }
73+ ```
74+
75+ - Data path: ` simple_series `
76+ - Time path: ` timestamp `
77+ - Time format: ` MM.DD.YYYY HHmmss `
5778
5879## Alias and group by
5980
6081``` graphql
6182query {
62- data : queryAll (from : " $__from" , to : " $__to" , sourceId : " default" ) {
63- batteryVoltage {
64- Time : dateMillis
65- packet {
66- batteryVoltage
67- identifier {
68- representation
69- }
70- identityInfo {
71- displayName
72- }
73- }
83+ complex_series (from : " ${__from:date:iso}" , to : " ${__to:date:iso}" , interval_ms : $__interval_ms ) {
84+ time {
85+ timestamp
86+ }
87+ value
88+ group {
89+ id
90+ name
7491 }
7592 }
7693}
7794```
7895
79- - Data path: ` data.batteryVoltage `
80- - Group by: ` packet.identifier.representation `
81- - Alias by: ` $field_packet.identityInfo.displayName `
96+ - Data path: ` complex_series `
97+ - Time path: ` time.timestamp `
98+ - Group by: ` group.id `
99+ - Alias by: ` $field_group.name `
82100
83101In the above example, "Group by" and "Alias by" are defined. "Group by" allows
84102you to split up an array of data into multiple data points. "Alias by" is used
85103as the name of the data point. You can make alias use text from the query or
86104even the field name by using ` $field_<your.field.name> ` for the value of the
87- field,
88- was used, it would be replaced by "batteryVoltage " because that's the name of
89- the field. If ` $field_identityInfo.displayName ` was used, it would be replaced
90- with the value of displayName . Using ` $fieldName ` can be useful if you're
91- querying multiple numeric fields that you want displayed in your graph.
105+ field, or ` $fieldName ` for the name of the field. If ` $fieldName ` was used, it
106+ would be replaced by "value " because that's the name of the field. If
107+ ` $field_group.name ` was used, it would be replaced with the value
108+ of ` name ` . Using ` $fieldName ` can be useful if you're querying multiple
109+ numeric fields that you want displayed in your graph.
92110
93111## Annotations
94112
95113``` graphql
96114query {
97- server1 : queryEvents (from : " $__from" , to : " $__to" , server : " server1" ) {
98- birthdayEvent {
99- Time : dateMillis
100- person {
101- fullName
102- }
103- }
104- }
105- server2 : queryEvents (from : " $__from" , to : " $__to" , server : " server2" ) {
106- birthdayEvent {
107- Time : dateMillis
108- person {
109- fullName
110- }
111- }
115+ events (from : " ${__from:date:iso}" , to : " ${__to:date:iso}" , end : true ) {
116+ timestamp
117+ end_timestamp
118+ name
119+ description
120+ tags
112121 }
113122}
114123```
115124
116- - Data path: ` server1.birthdayEvent, server2.birthdayEvent `
117- - Title: ` Birthday yay! `
118- - Text: ` $field_person.fullName `
125+ - Data path: ` events `
126+ - Time path: ` timestamp `
127+ - End time path: ` end_timestamp `
128+ - Title: ` $field_name `
129+ - Text: ` $field_description `
119130- Tags: ` tag1, tag2 `
120131
121- The above annotation example is similar to regular queries. You must have a
122- ` Time ` field and are able to define a data path. Similar to the last example,
123- you can also substitute values into the title, text, and tags by using
124- ` $field_<field name> ` . By using ` $field_person.fullName ` as the text, the text
125- in this annotation will be the person's full name. Tags are separated by commas.
126- The above example has two tags: "tag1" and "tag2". If a ` TimeEnd ` field is
127- present, the annotation will be shown over a period of time. You can also
128- separate the data path with commas to provide multiple data paths as shown with
129- both server1 and server2.
132+ The above annotation example is similar to regular queries. You are able to
133+ define a data path, time path, and time format. Similar to the last example, you
134+ can also substitute values into the title, text, and tags by using
135+ ` $field_<field name> ` . Tags are separated by commas. The above example has two
136+ tags: "tag1" and "tag2".
137+
138+ If the optional end time field is defined and present, the annotation will be
139+ shown over a period of time.
130140
131141## Dashboard Variable Queries
132142
@@ -138,13 +148,11 @@ the variable value list.
138148
139149``` graphql
140150query {
141- search (searchTerm : " $query" ) {
142- stations {
143- __value : primaryEvaId
144- __text : name
145- }
151+ groups {
152+ __value : id
153+ __text : name
146154 }
147155}
148156```
149157
150- - Data path: ` search.stations `
158+ - Data path: ` groups `
0 commit comments