Skip to content

Commit 9500f3c

Browse files
committed
value converter: added example
Signed-off-by: ngrebels <ngrebels@mathworks.com>
1 parent 3c3d029 commit 9500f3c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ modules:
6060
active: 1 # static value
6161
count: '{.count}' # dynamic value
6262
boolean: '{.some_boolean}'
63+
64+
- name: example_convert
65+
type: object
66+
path: '{.values[0,1]}'
67+
labels:
68+
state: '{.state}'
69+
values:
70+
state: '{.state}'
71+
valueconverter:
72+
'{.state}': #convert value 'state' into a number
73+
active: 1
74+
inactive: 2
6375

6476
headers:
6577
X-Dummy: my-test-header
@@ -70,6 +82,8 @@ Serving HTTP on 0.0.0.0 port 8000 ...
7082
$ ./json_exporter --config.file examples/config.yml &
7183

7284
$ curl "http://localhost:7979/probe?module=default&target=http://localhost:8000/examples/data.json" | grep ^example
85+
example_convert_state{state="ACTIVE"} 1
86+
example_convert_state{state="INACTIVE"} 2
7387
example_global_value{environment="beta",location="planet-mars"} 1234
7488
example_value_active{environment="beta",id="id-A"} 1
7589
example_value_active{environment="beta",id="id-C"} 1

examples/config.yml

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ modules:
2020
active: 1 # static value
2121
count: '{.count}' # dynamic value
2222
boolean: '{.some_boolean}'
23+
24+
- name: example_convert
25+
type: object
26+
path: '{.values[0,1]}'
27+
labels:
28+
state: '{.state}'
29+
values:
30+
state: '{.state}'
31+
valueconverter:
32+
'{.state}': #convert value 'state' in JSON into a number
33+
active: 1
34+
inactive: 2
35+
2336
headers:
2437
X-Dummy: my-test-header
2538

0 commit comments

Comments
 (0)