Skip to content

Commit

Permalink
value converter: added example
Browse files Browse the repository at this point in the history
Signed-off-by: ngrebels <[email protected]>
  • Loading branch information
ngrebels committed Aug 10, 2022
1 parent 3c3d029 commit 9500f3c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ modules:
active: 1 # static value
count: '{.count}' # dynamic value
boolean: '{.some_boolean}'
- name: example_convert
type: object
path: '{.values[0,1]}'
labels:
state: '{.state}'
values:
state: '{.state}'
valueconverter:
'{.state}': #convert value 'state' into a number
active: 1
inactive: 2

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

$ curl "http://localhost:7979/probe?module=default&target=http://localhost:8000/examples/data.json" | grep ^example
example_convert_state{state="ACTIVE"} 1
example_convert_state{state="INACTIVE"} 2
example_global_value{environment="beta",location="planet-mars"} 1234
example_value_active{environment="beta",id="id-A"} 1
example_value_active{environment="beta",id="id-C"} 1
Expand Down
13 changes: 13 additions & 0 deletions examples/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ modules:
active: 1 # static value
count: '{.count}' # dynamic value
boolean: '{.some_boolean}'

- name: example_convert
type: object
path: '{.values[0,1]}'
labels:
state: '{.state}'
values:
state: '{.state}'
valueconverter:
'{.state}': #convert value 'state' in JSON into a number
active: 1
inactive: 2

headers:
X-Dummy: my-test-header

Expand Down

0 comments on commit 9500f3c

Please sign in to comment.