fluent-plugin-influxdb-v2 1.5.0.pre.579

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # The MIT License
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+ #
23
+
24
+ set -e
25
+
26
+ echo "Wait to start InfluxDB 2.0"
27
+ wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:9999/metrics
28
+
29
+ echo
30
+ echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)"
31
+ echo
32
+ curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \
33
+ -d '{
34
+ "username": "my-user",
35
+ "password": "my-password",
36
+ "org": "my-org",
37
+ "bucket": "my-bucket",
38
+ "token": "my-token"
39
+ }'
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # The MIT License
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+ #
23
+
24
+ set -e
25
+
26
+ DEFAULT_DOCKER_REGISTRY="quay.io/influxdb/"
27
+ DOCKER_REGISTRY="${DOCKER_REGISTRY:-$DEFAULT_DOCKER_REGISTRY}"
28
+
29
+ DEFAULT_INFLUXDB_V2_REPOSITORY="influxdb"
30
+ DEFAULT_INFLUXDB_V2_VERSION="2.0.0-beta"
31
+ INFLUXDB_V2_REPOSITORY="${INFLUXDB_V2_REPOSITORY:-$DEFAULT_INFLUXDB_V2_REPOSITORY}"
32
+ INFLUXDB_V2_VERSION="${INFLUXDB_V2_VERSION:-$DEFAULT_INFLUXDB_V2_VERSION}"
33
+ INFLUXDB_V2_IMAGE=${DOCKER_REGISTRY}${INFLUXDB_V2_REPOSITORY}:${INFLUXDB_V2_VERSION}
34
+
35
+ SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
36
+
37
+ docker kill influxdb_v2 || true
38
+ docker rm influxdb_v2 || true
39
+ docker network rm influx_network || true
40
+ docker network create -d bridge influx_network --subnet 192.168.0.0/24 --gateway 192.168.0.1
41
+
42
+ #
43
+ # InfluxDB 2.0
44
+ #
45
+ echo
46
+ echo "Restarting InfluxDB 2.0 [${INFLUXDB_V2_IMAGE}] ... "
47
+ echo
48
+
49
+ docker pull "${INFLUXDB_V2_IMAGE}" || true
50
+ docker run \
51
+ --detach \
52
+ --name influxdb_v2 \
53
+ --network influx_network \
54
+ --publish 9999:9999 \
55
+ "${INFLUXDB_V2_IMAGE}"
56
+
57
+ #
58
+ # Post onBoarding request to InfluxDB 2
59
+ #
60
+ "${SCRIPT_PATH}"/influxdb-onboarding.sh
@@ -0,0 +1,190 @@
1
+ # InfluxDB 2 + Fluentd
2
+
3
+ InfluxDB 2 and Fluentd together are able to collect large amount of logs and transform it to useful metrics.
4
+ InfluxDB 2 provide a solution for realtime analysis and alerting over collected metrics.
5
+
6
+ <img src="architecture.png" height="400px">
7
+
8
+ ## Introduction
9
+
10
+ [Fluentd](https://www.fluentd.org/architecture) is an open source data collector, which lets you unify the data collection and consumption for a better use and understanding of data.
11
+
12
+ [InfluxDB](https://www.influxdata.com) open source time series database, purpose-built by InfluxData for monitoring metrics and events, provides real-time visibility into stacks, sensors, and systems.
13
+
14
+ ## Demo
15
+
16
+ The following demo show how to analyze logs (Apache Access Log) from dockerized environment.
17
+
18
+ > The steps from 1 to 6 could be skipped if you use a script:
19
+ >
20
+ > [`run-example.sh`](run-example.sh)
21
+ ### Prerequisites
22
+
23
+ - Docker installed on your computer
24
+
25
+ ### Step 1 — Create Docker Network
26
+
27
+ Create bridge network that allows smoothly communication between containers:
28
+
29
+ ```bash
30
+ docker network create -d bridge influx_network --subnet 192.168.0.0/24 --gateway 192.168.0.1
31
+ ```
32
+
33
+ ### Step 2 — Start InfluxDB
34
+
35
+ Start latest `InfluxDB 2`:
36
+
37
+ ```bash
38
+ docker run \
39
+ --detach \
40
+ --name influxdb_v2 \
41
+ --network influx_network \
42
+ --publish 9999:9999 \
43
+ quay.io/influxdb/influxdb:2.0.0-beta
44
+ ```
45
+
46
+ Create default organization, user and bucket:
47
+ ```bash
48
+ curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \
49
+ -d '{
50
+ "username": "my-user",
51
+ "password": "my-password",
52
+ "org": "my-org",
53
+ "bucket": "my-bucket",
54
+ "token": "my-token"
55
+ }'
56
+ ```
57
+
58
+ ### Step 3 — Prepare Fluentd Docker
59
+ We have to prepare a docker image that will contains Fluentd with configured [InfluxDB 2 output plugin](https://github.com/influxdata/influxdb-plugin-fluent/).
60
+
61
+ Fluentd is configured to parse incoming events with tag `httpd.access` by regexp: `/^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$/` to structured event with: `time`, `host`, `user`, `method`, `code` and `size`.
62
+ These structured events are routed to InfluxDB 2 output plugin.
63
+ #### Required files:
64
+
65
+ ##### Dockerfile
66
+
67
+ ```dockerfile
68
+ FROM fluent/fluentd:edge-debian
69
+
70
+ USER root
71
+
72
+ RUN fluent-gem install fluent-plugin-influxdb-v2
73
+
74
+ COPY ./fluent.conf /fluentd/etc/
75
+ COPY entrypoint.sh /bin/
76
+
77
+ USER fluent
78
+ ```
79
+
80
+ ##### fluent.conf
81
+
82
+ ```xml
83
+ <source>
84
+ @type forward
85
+ port 24224
86
+ bind 0.0.0.0
87
+ </source>
88
+ <source>
89
+ @type monitor_agent
90
+ bind 0.0.0.0
91
+ port 24220
92
+ </source>
93
+ <filter httpd.access>
94
+ @type parser
95
+ key_name log
96
+ <parse>
97
+ @type regexp
98
+ expression /^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$/
99
+ time_format %d/%b/%Y:%H:%M:%S %z
100
+ </parse>
101
+ </filter>
102
+ <match httpd.access>
103
+ @type copy
104
+ <store>
105
+ @type influxdb2
106
+ url http://influxdb_v2:9999
107
+ token my-token
108
+ bucket my-bucket
109
+ org my-org
110
+ use_ssl false
111
+ time_precision s
112
+ tag_keys ["method", "host", "path"]
113
+ <buffer tag>
114
+ @type memory
115
+ flush_interval 5
116
+ </buffer>
117
+ </store>
118
+ </match>
119
+ ```
120
+ Build image:
121
+
122
+ ```bash
123
+ docker build -t fluentd_influx .
124
+ ```
125
+ ### Step 4 — Start Fluentd image
126
+
127
+ ```bash
128
+ docker run \
129
+ --detach \
130
+ --name fluentd_influx \
131
+ --network influx_network \
132
+ --publish 24224:24224 \
133
+ --publish 24220:24220 \
134
+ fluentd_influx
135
+ ```
136
+
137
+ ### Step 5 — Start Apache HTTP Server
138
+
139
+ Docker includes multiple logging mechanisms to help you get information from running containers and services.
140
+
141
+ We will use [Fluentd](https://docs.docker.com/config/containers/logging/fluentd/) logging driver with configured tag as `httpd.access`:
142
+
143
+ ```bash
144
+ docker run \
145
+ --detach \
146
+ --name web \
147
+ --network influx_network \
148
+ --publish 8080:80 \
149
+ --log-driver fluentd \
150
+ --log-opt tag=httpd.access \
151
+ httpd
152
+ ```
153
+
154
+ ### Step 6 — Generate httpd Access Logs
155
+
156
+ Generate some access logs by curl:
157
+ ```bash
158
+ curl http://localhost:8080/
159
+ curl http://localhost:8080/not_exists
160
+ ```
161
+
162
+ ### Step 7 — Import Dashboard
163
+
164
+ Open [InfluxDB](http://localhost:9999) and import dashboard [web_app_access.json](influxdb/web_app_access.json) by following steps:
165
+
166
+ ```
167
+ username: my-user
168
+ password: my-password
169
+ ```
170
+
171
+ 1. Click the **Dashboards** icon in the navigation bar.
172
+ 1. Click the **Create Dashboard** menu in the upper right and select **Import Dashboard**.
173
+ 1. Select **Upload File** to drag-and-drop or select a **web_app_access.json**.
174
+ 1. Click **Import JSON** as Dashboard.
175
+
176
+ The imported dashboard should look like this:
177
+
178
+ <img src="dashboard.png" height="400px">
179
+
180
+
181
+ ## Conclusion
182
+
183
+ Analyze Apache Access Log is just one way how to use a power of InfluxDB and Fluentd.
184
+ There are other things you could do with InfluxDB and Fluentd such as: [Monitoring and alerting](https://v2.docs.influxdata.com/v2.0/monitor-alert/#manage-your-monitoring-and-alerting-pipeline).
185
+
186
+ ## Links
187
+
188
+ - https://www.digitalocean.com/community/tutorials/how-to-centralize-your-docker-logs-with-fluentd-and-elasticsearch-on-ubuntu-16-04
189
+ - https://stackoverflow.com/questions/58563760/docker-compose-pulls-an-two-images-an-app-and-fluentd-but-no-logs-are-sent-to-s
190
+ - https://docs.fluentd.org/v/0.12/container-deployment/docker-compose
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # The MIT License
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+ #
23
+
24
+ apk add parallel
25
+ cat /tmp/urls.txt | parallel "watch -n 5 ab -n 1000 -c 10 {}"
@@ -0,0 +1,4 @@
1
+ http://web:80/foo/bar/
2
+ http://web:80/
3
+ http://web:80/foo.html
4
+ http://web:80/parallelfoo/bar/?v=1
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ FROM fluent/fluentd:edge-debian
2
+
3
+ USER root
4
+
5
+ COPY ./fluent-plugin-influxdb-v2.gem /fluentd/plugins
6
+
7
+ RUN fluent-gem install /fluentd/plugins/fluent-plugin-influxdb-v2.gem
8
+
9
+ COPY ./fluent.conf /fluentd/etc/
10
+ COPY entrypoint.sh /bin/
11
+
12
+ USER fluent
@@ -0,0 +1,28 @@
1
+ #!/bin/sh
2
+
3
+ #source vars if file exists
4
+ DEFAULT=/etc/default/fluentd
5
+
6
+ if [ -r $DEFAULT ]; then
7
+ set -o allexport
8
+ . $DEFAULT
9
+ set +o allexport
10
+ fi
11
+
12
+ # If the user has supplied only arguments append them to `fluentd` command
13
+ if [ "${1#-}" != "$1" ]; then
14
+ set -- fluentd "$@"
15
+ fi
16
+
17
+ # If user does not supply config file or plugins, use the default
18
+ if [ "$1" = "fluentd" ]; then
19
+ if ! echo $@ | grep ' \-c' ; then
20
+ set -- "$@" -c /fluentd/etc/${FLUENTD_CONF}
21
+ fi
22
+
23
+ if ! echo $@ | grep ' \-p' ; then
24
+ set -- "$@" -p /fluentd/plugins
25
+ fi
26
+ fi
27
+
28
+ exec "$@"
@@ -0,0 +1,40 @@
1
+ <source>
2
+ @type forward
3
+ port 24224
4
+ bind 0.0.0.0
5
+ </source>
6
+ <source>
7
+ @type monitor_agent
8
+ bind 0.0.0.0
9
+ port 24220
10
+ </source>
11
+ <filter httpd.access>
12
+ @type parser
13
+ key_name log
14
+ <parse>
15
+ @type regexp
16
+ expression /^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$/
17
+ time_format %d/%b/%Y:%H:%M:%S %z
18
+ </parse>
19
+ </filter>
20
+ <match httpd.access>
21
+ @type copy
22
+ <store>
23
+ @type influxdb2
24
+ # @log_level trace
25
+ url http://influxdb_v2:9999
26
+ token my-token
27
+ bucket my-bucket
28
+ org my-org
29
+ use_ssl false
30
+ time_precision s
31
+ tag_keys ["method", "host", "path"]
32
+ <buffer tag>
33
+ @type memory
34
+ flush_interval 5
35
+ </buffer>
36
+ </store>
37
+ # <store>
38
+ # @type stdout
39
+ # </store>
40
+ </match>
@@ -0,0 +1,491 @@
1
+ {
2
+ "meta": {
3
+ "version": "1",
4
+ "type": "dashboard",
5
+ "name": "Web App Access-Template",
6
+ "description": "template created from dashboard: Web App Access"
7
+ },
8
+ "content": {
9
+ "data": {
10
+ "type": "dashboard",
11
+ "attributes": {
12
+ "name": "Web App Access",
13
+ "description": ""
14
+ },
15
+ "relationships": {
16
+ "label": {
17
+ "data": []
18
+ },
19
+ "cell": {
20
+ "data": [
21
+ {
22
+ "type": "cell",
23
+ "id": "0541daaaa9471000"
24
+ },
25
+ {
26
+ "type": "cell",
27
+ "id": "0541daaaaac71000"
28
+ },
29
+ {
30
+ "type": "cell",
31
+ "id": "0541daaaab071000"
32
+ },
33
+ {
34
+ "type": "cell",
35
+ "id": "0541daaaabc71000"
36
+ },
37
+ {
38
+ "type": "cell",
39
+ "id": "0541db0ef0871000"
40
+ }
41
+ ]
42
+ },
43
+ "variable": {
44
+ "data": []
45
+ }
46
+ }
47
+ },
48
+ "included": [
49
+ {
50
+ "id": "0541daaaa9471000",
51
+ "type": "cell",
52
+ "attributes": {
53
+ "x": 0,
54
+ "y": 0,
55
+ "w": 4,
56
+ "h": 4
57
+ },
58
+ "relationships": {
59
+ "view": {
60
+ "data": {
61
+ "type": "view",
62
+ "id": "0541daaaa9471000"
63
+ }
64
+ }
65
+ }
66
+ },
67
+ {
68
+ "id": "0541daaaaac71000",
69
+ "type": "cell",
70
+ "attributes": {
71
+ "x": 4,
72
+ "y": 0,
73
+ "w": 4,
74
+ "h": 4
75
+ },
76
+ "relationships": {
77
+ "view": {
78
+ "data": {
79
+ "type": "view",
80
+ "id": "0541daaaaac71000"
81
+ }
82
+ }
83
+ }
84
+ },
85
+ {
86
+ "id": "0541daaaab071000",
87
+ "type": "cell",
88
+ "attributes": {
89
+ "x": 6,
90
+ "y": 4,
91
+ "w": 6,
92
+ "h": 4
93
+ },
94
+ "relationships": {
95
+ "view": {
96
+ "data": {
97
+ "type": "view",
98
+ "id": "0541daaaab071000"
99
+ }
100
+ }
101
+ }
102
+ },
103
+ {
104
+ "id": "0541daaaabc71000",
105
+ "type": "cell",
106
+ "attributes": {
107
+ "x": 8,
108
+ "y": 0,
109
+ "w": 4,
110
+ "h": 4
111
+ },
112
+ "relationships": {
113
+ "view": {
114
+ "data": {
115
+ "type": "view",
116
+ "id": "0541daaaabc71000"
117
+ }
118
+ }
119
+ }
120
+ },
121
+ {
122
+ "id": "0541db0ef0871000",
123
+ "type": "cell",
124
+ "attributes": {
125
+ "x": 0,
126
+ "y": 4,
127
+ "w": 6,
128
+ "h": 4
129
+ },
130
+ "relationships": {
131
+ "view": {
132
+ "data": {
133
+ "type": "view",
134
+ "id": "0541db0ef0871000"
135
+ }
136
+ }
137
+ }
138
+ },
139
+ {
140
+ "type": "view",
141
+ "id": "0541daaaa9471000",
142
+ "attributes": {
143
+ "name": "Requests Count",
144
+ "properties": {
145
+ "shape": "chronograf-v2",
146
+ "type": "single-stat",
147
+ "queries": [
148
+ {
149
+ "text": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"httpd.access\")\n |> filter(fn: (r) => r._field == \"size\")\n |> drop(columns: [\"host\", \"method\", \"path\"])\n |> count()",
150
+ "editMode": "advanced",
151
+ "name": "",
152
+ "builderConfig": {
153
+ "buckets": [],
154
+ "tags": [
155
+ {
156
+ "key": "_measurement",
157
+ "values": []
158
+ }
159
+ ],
160
+ "functions": [],
161
+ "aggregateWindow": {
162
+ "period": "auto"
163
+ }
164
+ }
165
+ }
166
+ ],
167
+ "prefix": "",
168
+ "suffix": "",
169
+ "colors": [
170
+ {
171
+ "id": "base",
172
+ "type": "text",
173
+ "hex": "#00C9FF",
174
+ "name": "laser",
175
+ "value": 0
176
+ }
177
+ ],
178
+ "decimalPlaces": {
179
+ "isEnforced": true,
180
+ "digits": 2
181
+ },
182
+ "note": "",
183
+ "showNoteWhenEmpty": false
184
+ }
185
+ }
186
+ },
187
+ {
188
+ "type": "view",
189
+ "id": "0541daaaaac71000",
190
+ "attributes": {
191
+ "name": "Request Size",
192
+ "properties": {
193
+ "shape": "chronograf-v2",
194
+ "type": "single-stat",
195
+ "queries": [
196
+ {
197
+ "text": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"httpd.access\")\n |> filter(fn: (r) => r.method == \"GET\")\n |> filter(fn: (r) => r._field == \"size\")\n |> drop(columns: [\"path\"])\n |> toInt()\n |> sum(column: \"_value\")\n |> map(fn: (r) => ({\n r with\n _value: r._value / 1024\n })\n )",
198
+ "editMode": "advanced",
199
+ "name": "",
200
+ "builderConfig": {
201
+ "buckets": [],
202
+ "tags": [
203
+ {
204
+ "key": "_measurement",
205
+ "values": []
206
+ }
207
+ ],
208
+ "functions": [],
209
+ "aggregateWindow": {
210
+ "period": "auto"
211
+ }
212
+ }
213
+ }
214
+ ],
215
+ "prefix": "",
216
+ "suffix": " KiB",
217
+ "colors": [
218
+ {
219
+ "id": "base",
220
+ "type": "text",
221
+ "hex": "#F48D38",
222
+ "name": "tiger",
223
+ "value": 0
224
+ }
225
+ ],
226
+ "decimalPlaces": {
227
+ "isEnforced": true,
228
+ "digits": 2
229
+ },
230
+ "note": "",
231
+ "showNoteWhenEmpty": false
232
+ }
233
+ }
234
+ },
235
+ {
236
+ "type": "view",
237
+ "id": "0541daaaab071000",
238
+ "attributes": {
239
+ "name": "Requests Count",
240
+ "properties": {
241
+ "shape": "chronograf-v2",
242
+ "queries": [
243
+ {
244
+ "text": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"httpd.access\")\n |> filter(fn: (r) => r._field == \"code\")\n |> drop(columns: [\"method\", \"host\"])\n |> aggregateWindow(every: 1m, fn: count)",
245
+ "editMode": "advanced",
246
+ "name": "",
247
+ "builderConfig": {
248
+ "buckets": [],
249
+ "tags": [
250
+ {
251
+ "key": "_measurement",
252
+ "values": []
253
+ }
254
+ ],
255
+ "functions": [],
256
+ "aggregateWindow": {
257
+ "period": "auto"
258
+ }
259
+ }
260
+ }
261
+ ],
262
+ "axes": {
263
+ "x": {
264
+ "bounds": [
265
+ "",
266
+ ""
267
+ ],
268
+ "label": "",
269
+ "prefix": "",
270
+ "suffix": "",
271
+ "base": "10",
272
+ "scale": "linear"
273
+ },
274
+ "y": {
275
+ "bounds": [
276
+ "",
277
+ ""
278
+ ],
279
+ "label": "",
280
+ "prefix": "",
281
+ "suffix": "",
282
+ "base": "10",
283
+ "scale": "linear"
284
+ }
285
+ },
286
+ "type": "xy",
287
+ "legend": {},
288
+ "geom": "line",
289
+ "colors": [
290
+ {
291
+ "id": "56d087db-1d89-453c-8787-d5b5368b608f",
292
+ "type": "scale",
293
+ "hex": "#31C0F6",
294
+ "name": "Nineteen Eighty Four",
295
+ "value": 0
296
+ },
297
+ {
298
+ "id": "e5d0bd7c-cded-4ed2-aa55-94e920105d6e",
299
+ "type": "scale",
300
+ "hex": "#A500A5",
301
+ "name": "Nineteen Eighty Four",
302
+ "value": 0
303
+ },
304
+ {
305
+ "id": "e5f1b958-099c-4d84-8e78-8a460b8193e5",
306
+ "type": "scale",
307
+ "hex": "#FF7E27",
308
+ "name": "Nineteen Eighty Four",
309
+ "value": 0
310
+ }
311
+ ],
312
+ "note": "",
313
+ "showNoteWhenEmpty": false,
314
+ "xColumn": "_time",
315
+ "yColumn": "_value",
316
+ "shadeBelow": true,
317
+ "position": "overlaid",
318
+ "timeFormat": ""
319
+ }
320
+ }
321
+ },
322
+ {
323
+ "type": "view",
324
+ "id": "0541daaaabc71000",
325
+ "attributes": {
326
+ "name": "Success rate",
327
+ "properties": {
328
+ "shape": "chronograf-v2",
329
+ "type": "single-stat",
330
+ "queries": [
331
+ {
332
+ "text": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"httpd.access\")\n |> filter(fn: (r) => r._field == \"code\")\n |> drop(columns: [\"path\", \"method\", \"host\"])\n |> toInt()\n |> map(fn: (r) => ({ \n _time: r._start,\n _success:\n if r._value < 300 then 1\n else 0,\n _failure:\n if r._value >= 300 then 1\n else 0\n })\n )\n |> cumulativeSum(columns: [\"_failure\", \"_success\"])\n |> drop(columns: [\"_time\"])\n |> map(fn: (r) => ({\n r with\n _value: (float(v: r._success) / (float(v: r._success) + float(v: r._failure))) * 100.0\n })\n)\n |> last()",
333
+ "editMode": "advanced",
334
+ "name": "",
335
+ "builderConfig": {
336
+ "buckets": [],
337
+ "tags": [
338
+ {
339
+ "key": "_measurement",
340
+ "values": []
341
+ }
342
+ ],
343
+ "functions": [],
344
+ "aggregateWindow": {
345
+ "period": "auto"
346
+ }
347
+ }
348
+ }
349
+ ],
350
+ "prefix": "",
351
+ "suffix": "%",
352
+ "colors": [
353
+ {
354
+ "id": "base",
355
+ "type": "text",
356
+ "hex": "#00C9FF",
357
+ "name": "laser",
358
+ "value": 0
359
+ },
360
+ {
361
+ "id": "5e50c5ba-51cc-4139-870f-663050d6e79d",
362
+ "type": "text",
363
+ "hex": "#F48D38",
364
+ "name": "tiger",
365
+ "value": 80
366
+ },
367
+ {
368
+ "id": "305d340f-09e5-4137-b88b-0a6599209dc0",
369
+ "type": "text",
370
+ "hex": "#7CE490",
371
+ "name": "honeydew",
372
+ "value": 90
373
+ }
374
+ ],
375
+ "decimalPlaces": {
376
+ "isEnforced": true,
377
+ "digits": 2
378
+ },
379
+ "note": "",
380
+ "showNoteWhenEmpty": false
381
+ }
382
+ }
383
+ },
384
+ {
385
+ "type": "view",
386
+ "id": "0541db0ef0871000",
387
+ "attributes": {
388
+ "name": "Requests",
389
+ "properties": {
390
+ "shape": "chronograf-v2",
391
+ "type": "table",
392
+ "queries": [
393
+ {
394
+ "text": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"httpd.access\")",
395
+ "editMode": "advanced",
396
+ "name": "",
397
+ "builderConfig": {
398
+ "buckets": [],
399
+ "tags": [
400
+ {
401
+ "key": "_measurement",
402
+ "values": []
403
+ }
404
+ ],
405
+ "functions": [],
406
+ "aggregateWindow": {
407
+ "period": "auto"
408
+ }
409
+ }
410
+ }
411
+ ],
412
+ "colors": [
413
+ {
414
+ "id": "base",
415
+ "type": "text",
416
+ "hex": "#00C9FF",
417
+ "name": "laser",
418
+ "value": 0
419
+ }
420
+ ],
421
+ "tableOptions": {
422
+ "verticalTimeAxis": true,
423
+ "sortBy": {
424
+ "internalName": "",
425
+ "displayName": "",
426
+ "visible": false
427
+ },
428
+ "wrapping": "",
429
+ "fixFirstColumn": false
430
+ },
431
+ "fieldOptions": [
432
+ {
433
+ "internalName": "_start",
434
+ "displayName": "_start",
435
+ "visible": false
436
+ },
437
+ {
438
+ "internalName": "_stop",
439
+ "displayName": "_stop",
440
+ "visible": false
441
+ },
442
+ {
443
+ "internalName": "_time",
444
+ "displayName": "Time",
445
+ "visible": true
446
+ },
447
+ {
448
+ "internalName": "host",
449
+ "displayName": "Host",
450
+ "visible": true
451
+ },
452
+ {
453
+ "internalName": "path",
454
+ "displayName": "Path",
455
+ "visible": true
456
+ },
457
+ {
458
+ "internalName": "method",
459
+ "displayName": "Method",
460
+ "visible": true
461
+ },
462
+ {
463
+ "internalName": "_field",
464
+ "displayName": "Field",
465
+ "visible": true
466
+ },
467
+ {
468
+ "internalName": "_value",
469
+ "displayName": "Value",
470
+ "visible": true
471
+ },
472
+ {
473
+ "internalName": "_measurement",
474
+ "displayName": "_measurement",
475
+ "visible": false
476
+ }
477
+ ],
478
+ "timeFormat": "YYYY-MM-DD HH:mm:ss",
479
+ "decimalPlaces": {
480
+ "isEnforced": false,
481
+ "digits": 2
482
+ },
483
+ "note": "",
484
+ "showNoteWhenEmpty": false
485
+ }
486
+ }
487
+ }
488
+ ]
489
+ },
490
+ "labels": []
491
+ }