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: README.md
+28-11Lines changed: 28 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,7 +129,7 @@ The Group By clause should be the country code and an alias is needed too. The a
129
129
130
130

131
131
132
-
#### Elasticseach Query for Countries
132
+
#### Elasticsearch Query for Countries
133
133
134
134
Use a Group By clause on the field containing the country code and a Then by clause with Date Histogram by `@timestamp` (or corresponding date field).
135
135
@@ -139,7 +139,7 @@ Use a Group By clause on the field containing the country code and a Then by cla
139
139
140
140
Under the Worldmap tab, choose either the `countries` or `states` option.
141
141
142
-

142
+

143
143
144
144
Using a JSON endpoint to return a custom list of locations:
145
145
@@ -176,17 +176,32 @@ Three fields need to be provided by the ElasticSearch query:
176
176
Supported Databases:
177
177
178
178
- InfluxDB
179
+
- Elasticsearch
180
+
- MySQL, Postgres, MSSQL
181
+
- Any database that can return data in Table Format
182
+
183
+
If a datasource can return Table Data then on the Metrics tab in Grafana choose the `FORMAT AS` Table option.
179
184
180
-
An example of Table Data would using InfluxDB and then formatting the data returned from the metric query as Table.
185
+
### Table Data with a Geohash Column
181
186
182
187
Similar to the Elasticsearch query above, 3 fields are expected (2 of them are mandatory)
183
188
184
-
- a field named *metric*
185
-
- a geohash tag named *geohash*
186
-
- an optional location name (shown in the mouse over). This location name has to be specified in the Worldmap settings tab too.
189
+
- A *metric* field. This is used to give the circle a value and determines how large the circle is.
190
+
- A *geohash* field. This is used to calculate where the circle should be drawn.
191
+
- an optional location name field (shown in the mouse over). Used to label each circle on the map. If it is empty then the geohash value is used as the label.
192
+
193
+
The field mappings have to be specified on the Worldmap settings tab.
### Table Data with Latitude and Longitude Columns
198
+
199
+
The Table Data format also works with two columns for latitude and longitude instead of a geohash column.
200
+
201
+
- A *metric* field. This is used to give the circle a value and determines how large the circle is.
202
+
- Latitude/Longitude Fields. These are used to calculate where the circle should be drawn.
203
+
- an optional location name field (shown in the mouse over). Used to label each circle on the map. If it is empty then the geohash value is used as the label.
204
+
190
205
## JSON result as the Data Source
191
206
192
207
Supported Databases:
@@ -197,17 +212,18 @@ It supports any datasource capable of generating a JSON response with a a custo
197
212
198
213
### Map Data Options
199
214
200
-
**Location Data**
215
+
#### Location Data
201
216
202
217
There are four ways to provide data for the worldmap panel:
218
+
203
219
-*countries*: This is a list of all the countries in the world. It works by matching a country code (US, FR, AU) to a node alias in a time series query.
204
220
-*states*: Similar to countries but for the states in USA e.g. CA for California
205
221
-*geohash*: An ElasticSearch query that returns geohashes.
206
222
-*json*: A json endpoint that returns custom json. Examples of the format are the [countries data used in first option](https://github.com/grafana/worldmap-panel/blob/master/src/data/countries.json) or [this list of cities](https://github.com/grafana/worldmap-panel/blob/master/src/data/probes.json).
207
223
-*jsonp*: A jsonp endpoint that returns custom json wrapped as jsonp. Use this if you are having problems with CORS.
208
-
-*table*: This expects the metric query to return data points with a field named geohash. This field should contain a string in the [geohash form](https://www.elastic.co/guide/en/elasticsearch/guide/current/geohashes.html). For example: London -> "gcpvh3zgu992".
224
+
-*table*: This expects the metric query to return data points with a field named geohash or two fields/columns named `latitude` and `longitude`. This field should contain a string in the [geohash form](https://www.elastic.co/guide/en/elasticsearch/guide/current/geohashes.html). For example: London -> "gcpvh3zgu992".
209
225
210
-
**Aggregation**
226
+
#### Aggregation
211
227
212
228
If you chose *countries* or *table* as the source of the location data then you can choose an aggregation here: avg, total etc.
213
229
@@ -219,10 +235,11 @@ Or just remove the 1 from the Max Data Point field and use the consolidation fun
219
235
220
236

221
237
222
-
**ES Metric/Location Name/geo_point Field**
238
+
#### ES Metric/Location Name/geo_point Field
223
239
224
240
Three fields need to be provided by the ElasticSearch query. They are text fields and should be the field names from the query under the Metrics tab.
225
-
- Metric is one of Count, Average, Sum etc.
241
+
242
+
- The Metric in Elasticsearch is one of `Count`, `Average`, `Sum` etc.
226
243
- Location Name is the field that gives the circle a name. If it is blank, then the geohash value is shown in the popover instead of the location.
227
244
- geo_point is the GeoHashGrid field that provides the geohash value.
The Worldmap Panel is a tile map of the world that can be overlaid with circles representing data points from a query. It can be used with time series metrics, with geohash data from Elasticsearch or Table Data.
3
+
The Worldmap Panel is a tile map of the world that can be overlaid with circles representing data points from a query. It can be used with time series metrics, with geohash data from Elasticsearch or data in the Table format.
There are currently two ways to connect data with points on a map. Either by matching a tag or series name to a country code/state code (e.g. SE for Sweden, TX for Texas) or by using geohashes to map against geographic coordinates.
7
+
## How The Worldmap Works (Theory and Examples)
8
+
9
+
The Worldmap panel needs two sources of data:
10
+
11
+
- a location (latitude and longitude)
12
+
- data that has a link to a location
13
+
14
+
The data comes from a database query: Prometheus, InfluxDB, Graphite, Elasticsearch, MySQL etc. It can be in the Time Series format or in the Table format.
15
+
16
+
### Time Series Format
17
+
18
+
If it is in the **Time Series format** then the metric name needs to match a key from a list of locations. That key is usually a country code or city name. The list of locations can come from a file or an HTTP endpoint.
19
+
20
+
The list of locations can be provided in several ways:
21
+
22
+
- json files with locations and their coordinates (the plugin includes list for countries and US states)
23
+
- json endpoints that return a list of locations and their coordinates
24
+
25
+
Time Series data contains a timestamp, a metric name and a numeric value. In other words, a typical query for a time series database. Here is some time series data from Graphite:
Location data should be in the JSON format and should be an array of JSON objects with four properties:
35
+
36
+
```json
37
+
[
38
+
{
39
+
"key": "SE",
40
+
"latitude": 60.128161,
41
+
"longitude": 18.643501,
42
+
"name": "Sweden"
43
+
},
44
+
{
45
+
"key": "US",
46
+
"latitude": 37.09024,
47
+
"longitude": -95.712891,
48
+
"name": "United States"
49
+
}
50
+
]
51
+
```
52
+
53
+
The Worldmap will then match the metric name (target in the example data) with a key field from the location data. With this example data there will be two circles drawn on the map, one for Sweden and one for the United States with values 183255 and 192224.
54
+
55
+
### Table Format
56
+
57
+
If the data is in the **Table format** then it should have a column that is a geohash or two columns that contain the latitude and longitude (together with the columns for the data).
58
+
59
+
Table data is tabular data with columns and rows. Here is an example of Table data from InfluxDB:
60
+
61
+
```json
62
+
"series": [
63
+
{
64
+
"name": "logins.count",
65
+
"tags": {
66
+
"geohash": "9wvfgzurfzb"
67
+
},
68
+
"columns": [
69
+
"time",
70
+
"metric"
71
+
],
72
+
"values": [
73
+
[
74
+
1529762933815,
75
+
75.654324173059
76
+
]
77
+
]
78
+
}
79
+
]
80
+
```
81
+
82
+
This query contains both data (the value `75.654324173059`) and a location (the geohash `9wvfgzurfzb` which is in Colorado). So using these, the Worldmap panel will draw one circle in Colorado, USA with the value 75.654324173059.
8
83
9
84
## Time Series Data as the Data Source
10
85
@@ -14,35 +89,47 @@ Supported Databases:
14
89
- InfluxDB
15
90
- OpenTSDB
16
91
- Prometheus
92
+
- MySQL
93
+
- Postgres
94
+
- MSSQL
17
95
- Elasticsearch
18
96
19
-
Included location data:
97
+
The following location files are included in the plugin:
20
98
21
99
- Countries (2 letter codes)
22
100
- Countries (3 letter codes)
23
101
- US states
24
102
25
-
This works by matching country codes (like US or GB or FR) or US state codes (TX or NY) to a node or a wildcard in a metric namespace. If there is a match in the list of countries or states then a circle will be drawn at the location.
103
+
Alternatively, you can provide your own location lists by using:
104
+
105
+
- A JSON endpoint that returns a list of locations
106
+
- A JSONP endpoint that returns a list of locations
107
+
108
+
This works by matching country codes (like US or GB or FR) or US state codes (TX or NY) to a metric name. If a metric name matches a country in the list of countries then a circle will be drawn at that location.
26
109
27
110
If you want to match to other data than countries or states, then you will have to provide custom location data. The current way to do that is via a JSON endpoint that returns a json file with location data (See Map Data Options)
28
111
29
112
The size of the circle depends on the value of the matched metric. Circle size is relative e.g. if you have 3 countries with values 1, 2 and 3 or 100, 200 and 300 then you will get one small circle, one medium circle and one large circle.
30
113
31
-
#### Query Examples
114
+
### Time Series - Graphite and InfluxDB
115
+
116
+
Here are some examples of Time Series Queries
32
117
33
-
#### Graphite Query for Countries
118
+
#### Graphite Query
34
119
35
120
Use the aliasByNode function to point to the field containing the country code. See the image below for an example of a graphite query.
36
121
37
122

38
123
39
-
#### Influx Query for Countries
124
+
Example dashboard for Worldmap with Graphite queries on [the Grafana play site](http://localhost:3000/d/000000003/worldmap-panels?panelId=8&fullscreen&edit&orgId=1).
125
+
126
+
#### InfluxDB Query
40
127
41
128
The Group By clause should be the country code and an alias is needed too. The alias should be in the form `$tag_<field name>`.
42
129
43
130

44
131
45
-
#### Elasticseach Query for Countries
132
+
#### Elasticsearch Query for Countries
46
133
47
134
Use a Group By clause on the field containing the country code and a Then by clause with Date Histogram by `@timestamp` (or corresponding date field).
48
135
@@ -84,72 +171,59 @@ Three fields need to be provided by the ElasticSearch query:
84
171
85
172

86
173
87
-
88
174
## Table Data as the Data Source
89
175
90
176
Supported Databases:
91
177
92
178
- InfluxDB
179
+
- Elasticsearch
180
+
- MySQL, Postgres, MSSQL
181
+
- Any database that can return data in Table Format
93
182
94
-
An example of Table Data would using InfluxDB and then formatting the data returned from the metric query as Table.
95
-
96
-
Similar to the Elasticsearch query above, 3 fields are expected (2 of them are mandatory)
97
-
98
-
- a field named *metric*
99
-
- a geohash tag named *geohash*
100
-
- an optional location name (shown in the mouse over). This location name has to be specified in the Worldmap settings tab too.
- Warp 10 via [grafana-warp10-datasource](https://github.com/cityzendata/grafana-warp10) plugin
110
-
111
-
It supports any datasource capable of generating a JSON response with a a custom list of locations (the same format that for the JSON enpoint).
112
-
113
-
### Map Visual Option Settings
183
+
If a datasource can return Table Data then on the Metrics tab in Grafana choose the `FORMAT AS` Table option.
114
184
115
-
**Center**
185
+
### Table Data with a Geohash Column
116
186
117
-
This settings configures the default center of the map. There are 5 centers to choose from or you can choose a custom center or last GeoHash center..For a custom center there are two fields: latitude and longitude. Examples of values are 37.09024, -95.712891 for the center of the US or 55.378051, -3.435973 for Great Britain. Last GeoHash center will centered the map on the last GeoHash received from the data.
187
+
Similar to the Elasticsearch query above, 3 fields are expected (2 of them are mandatory)
118
188
189
+
- A *metric* field. This is used to give the circle a value and determines how large the circle is.
190
+
- A *geohash* field. This is used to calculate where the circle should be drawn.
191
+
- an optional location name field (shown in the mouse over). Used to label each circle on the map. If it is empty then the geohash value is used as the label.
119
192
120
-
**Initial Zoom**
193
+
The field mappings have to be specified on the Worldmap settings tab.
121
194
122
-
The initial zoom factor for the map. This is a value between 1 and 18 where 1 is the most zoomed out.
### Table Data with Latitude and Longitude Columns
127
198
128
-
**Max Circle Size**
199
+
The Table Data format also works with two columns for latitude and longitude instead of a geohash column.
129
200
130
-
This is the maximum size for a circle in pixels. Depending on the zoom level you might want a larger or smaller max circle size to avoid overlapping.
201
+
- A *metric* field. This is used to give the circle a value and determines how large the circle is.
202
+
- Latitude/Longitude Fields. These are used to calculate where the circle should be drawn.
203
+
- an optional location name field (shown in the mouse over). Used to label each circle on the map. If it is empty then the geohash value is used as the label.
131
204
132
-
**Unit**
205
+
## JSON result as the Data Source
133
206
134
-
The Unit is shown in the popover when you hover over a circle. There are two fields the singular form and the plural form. E.g. visit/visits or error/errors
207
+
Supported Databases:
135
208
136
-
**Show Legend**
209
+
- Warp 10 via [grafana-warp10-datasource](https://github.com/cityzendata/grafana-warp10) plugin
137
210
138
-
Shows/hide the legend on the bottom left that shows the threshold ranges and their associated colors.
211
+
It supports any datasource capable of generating a JSON response with a a custom list of locations (the same format that for the JSON enpoint).
139
212
140
213
### Map Data Options
141
214
142
-
**Location Data**
215
+
#### Location Data
143
216
144
217
There are four ways to provide data for the worldmap panel:
218
+
145
219
-*countries*: This is a list of all the countries in the world. It works by matching a country code (US, FR, AU) to a node alias in a time series query.
146
220
-*states*: Similar to countries but for the states in USA e.g. CA for California
147
221
-*geohash*: An ElasticSearch query that returns geohashes.
148
222
-*json*: A json endpoint that returns custom json. Examples of the format are the [countries data used in first option](https://github.com/grafana/worldmap-panel/blob/master/src/data/countries.json) or [this list of cities](https://github.com/grafana/worldmap-panel/blob/master/src/data/probes.json).
149
223
-*jsonp*: A jsonp endpoint that returns custom json wrapped as jsonp. Use this if you are having problems with CORS.
150
-
-*table*: This expects the metric query to return data points with a field named geohash. This field should contain a string in the [geohash form](https://www.elastic.co/guide/en/elasticsearch/guide/current/geohashes.html). For example: London -> "gcpvh3zgu992".
224
+
-*table*: This expects the metric query to return data points with a field named geohash or two fields/columns named `latitude` and `longitude`. This field should contain a string in the [geohash form](https://www.elastic.co/guide/en/elasticsearch/guide/current/geohashes.html). For example: London -> "gcpvh3zgu992".
151
225
152
-
**Aggregation**
226
+
#### Aggregation
153
227
154
228
If you chose *countries* or *table* as the source of the location data then you can choose an aggregation here: avg, total etc.
155
229
@@ -161,13 +235,40 @@ Or just remove the 1 from the Max Data Point field and use the consolidation fun
161
235
162
236

163
237
164
-
**ES Metric/Location Name/geo_point Field**
238
+
#### ES Metric/Location Name/geo_point Field
165
239
166
240
Three fields need to be provided by the ElasticSearch query. They are text fields and should be the field names from the query under the Metrics tab.
167
-
- Metric is one of Count, Average, Sum etc.
241
+
242
+
- The Metric in Elasticsearch is one of `Count`, `Average`, `Sum` etc.
168
243
- Location Name is the field that gives the circle a name. If it is blank, then the geohash value is shown in the popover instead of the location.
169
244
- geo_point is the GeoHashGrid field that provides the geohash value.
170
245
246
+
### Map Visual Option Settings
247
+
248
+
**Center**
249
+
250
+
This settings configures the default center of the map. There are 5 centers to choose from or you can choose a custom center or last GeoHash center..For a custom center there are two fields: latitude and longitude. Examples of values are 37.09024, -95.712891 for the center of the US or 55.378051, -3.435973 for Great Britain. Last GeoHash center will centered the map on the last GeoHash received from the data.
251
+
252
+
**Initial Zoom**
253
+
254
+
The initial zoom factor for the map. This is a value between 1 and 18 where 1 is the most zoomed out.
255
+
256
+
**Min Circle Size**
257
+
258
+
This is minimum size for a circle in pixels.
259
+
260
+
**Max Circle Size**
261
+
262
+
This is the maximum size for a circle in pixels. Depending on the zoom level you might want a larger or smaller max circle size to avoid overlapping.
263
+
264
+
**Unit**
265
+
266
+
The Unit is shown in the popover when you hover over a circle. There are two fields the singular form and the plural form. E.g. visit/visits or error/errors
267
+
268
+
**Show Legend**
269
+
270
+
Shows/hide the legend on the bottom left that shows the threshold ranges and their associated colors.
0 commit comments