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
A [prometheus](https://prometheus.io/) exporter which scrapes remote JSON by JSONPath.
6
-
For checking the JSONPath configuration supported by this exporter please head over [here](https://kubernetes.io/docs/reference/kubectl/jsonpath/).
7
-
Checkout the [examples](/examples) directory for sample exporter configuration, prometheus configuration and expected data format.
8
6
9
-
#### :warning: The configuration syntax has changed in version `0.3.x`. If you are migrating from `0.2.x`, then please use the above mentioned JSONPath guide for correct configuration syntax.
$ docker run --rm -it -p 9090:9090 -v $PWD/examples/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
83
57
```
84
58
Then head over to http://localhost:9090/graph?g0.range_input=1h&g0.expr=example_value_active&g0.tab=1 or http://localhost:9090/targets to check the scraped metrics or the targets.
85
59
86
60
## Using custom timestamps
87
61
88
-
This exporter allows you to use a field of the metric as the (unix/epoch) timestamp for the data as an int64. However, this may lead to unexpected behaviour, as the prometheus implements a [Staleness](https://prometheus.io/docs/prometheus/latest/querying/basics/#staleness) mechanism. Including timestamps in metrics disabled this staleness handling and can make data visible for longer than expected.
89
-
90
-
## Exposing metrics through HTTPS
62
+
This exporter allows you to use a field of the metric as the (unix/epoch) timestamp for the data as an int64. However, this may lead to unexpected behaviour, as the prometheus implements a [Staleness](https://prometheus.io/docs/prometheus/latest/querying/basics/#staleness) mechanism.
91
63
92
-
TLS configuration supported by this exporter can be found at [exporter-toolkit/web](https://github.com/prometheus/exporter-toolkit/blob/v0.5.1/docs/web-configuration.md)
64
+
:warning: Including timestamps in metrics disables the staleness handling and can make data visible for longer than expected.
93
65
94
-
## Build
66
+
## Exposing metrics through HTTPS
95
67
96
-
```sh
97
-
make build
98
-
```
68
+
TLS configuration supported by this exporter can be found at [exporter-toolkit/web](https://github.com/prometheus/exporter-toolkit/blob/v0.9.0/docs/web-configuration.md)
99
69
100
70
## Sending body content for HTTP `POST`
101
71
102
-
If `body` paramater is set in config, it will be sent by the exporter as the body content in the scrape request. The HTTP method will also be set as 'POST' in this case.
72
+
If `modules.<module_name>.body` paramater is set in config, it will be sent by the exporter as the body content in the scrape request. The HTTP method will also be set as 'POST' in this case.
103
73
```yaml
104
74
body:
105
75
content: |
@@ -132,9 +102,6 @@ Then `curl "http://exporter:7979/probe?target=http://scrape_target:8080/test/dat
132
102
## Docker
133
103
134
104
```console
135
-
docker run \
136
-
-v $PWD/examples/config.yml:/config.yml \
137
-
quay.io/prometheuscommunity/json-exporter \
138
-
--config.file=/config.yml
105
+
$ docker run -v $PWD/examples/config.yml:/config.yml quay.io/prometheuscommunity/json-exporter --config.file=/config.yml
help: Example of a top-level global value scrape in the json
8
10
labels:
9
11
environment: beta # static label
10
-
location: "planet-{.location}"# dynamic label
12
+
location: 'planet-{.location}'# dynamic label
11
13
- name: example_timestamped_value
14
+
type: object
12
15
path: '{ .values[?(@.state == "INACTIVE")] }'
13
-
epochTimestamp: "{ .timestamp }"
16
+
epochTimestamp: '{ .timestamp }'
14
17
help: Example of a timestamped value scrape in the json
15
18
labels:
16
19
environment: beta # static label
20
+
values:
21
+
count: '{.count}'# dynamic value
17
22
- name: example_value
18
23
type: object
19
24
help: Example of sub-level value scrapes from a json
20
25
path: '{.values[?(@.state == "ACTIVE")]}'
21
26
labels:
22
27
environment: beta # static label
23
-
id: '{.id}'# dynamic label
28
+
id: '{.id}'# dynamic label
24
29
values:
25
-
active: 1# static value
30
+
active: 1# static value
26
31
count: '{.count}'# dynamic value
27
32
boolean: '{.some_boolean}'
28
-
headers:
29
-
X-Dummy: my-test-header
30
33
31
-
# If 'body' is set, it will be sent by the exporter as the body content in the scrape request. The HTTP method will also be set as 'POST' in this case.
# The body content can also be a Go Template (https://golang.org/pkg/text/template), with all the functions from the Sprig library (https://masterminds.github.io/sprig/) available. All the query parameters sent by prometheus in the scrape query to the exporter, are available in the template.
help: Example of top-level lists in a separate module
39
+
path: '{ [*] }'
40
+
labels:
41
+
name: '{ .noun }'
42
+
predator: '{ .predator }'
43
+
values:
44
+
population: '{ .population }'
41
45
42
-
# For full http client config parameters, ref: https://pkg.go.dev/github.com/prometheus/common/config?tab=doc#HTTPClientConfig
46
+
## HTTP connection configurations can be set in 'modules.<module_name>.http_client_config' field. For full http client config parameters, ref: https://pkg.go.dev/github.com/prometheus/common/config?tab=doc#HTTPClientConfig
43
47
#
44
48
# http_client_config:
45
49
# tls_config:
@@ -49,5 +53,17 @@ modules:
49
53
# #password: veryverysecret
50
54
# password_file: /tmp/mysecret.txt
51
55
52
-
# Accepted status codes for this probe. Defaults to 2xx.
## If 'modueles.<module_name>.body' field is set, it will be sent by the exporter as the body content in the scrape request. The HTTP method will also be set as 'POST' in this case.
## The body content can also be a Go Template (https://golang.org/pkg/text/template), with all the functions from the Sprig library (https://masterminds.github.io/sprig/) available. All the query parameters sent by prometheus in the scrape query to the exporter, are available in the template.
0 commit comments