From 9500f3c6cc27f9b24cab0c9f17a77d4dadfb10a2 Mon Sep 17 00:00:00 2001 From: ngrebels Date: Wed, 10 Aug 2022 15:20:52 -0400 Subject: [PATCH] value converter: added example Signed-off-by: ngrebels --- README.md | 14 ++++++++++++++ examples/config.yml | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 09ca7c53..646ebd93 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/examples/config.yml b/examples/config.yml index 5db61ea7..620e108c 100644 --- a/examples/config.yml +++ b/examples/config.yml @@ -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