-
Notifications
You must be signed in to change notification settings - Fork 206
Support Value Conversions #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
327cf2d
Bump k8s.io/client-go from 0.24.2 to 0.24.3 (#171)
dependabot[bot] 85ef5d8
Bump github.com/prometheus/common from 0.35.0 to 0.37.0 (#170)
dependabot[bot] 852d51b
Added a value converter for dynamic values and associated tests
ngrebels 41dc001
Refactored into functions and created a type
ngrebels 4304ba2
value converter: added example
ngrebels 52a4267
Remove underscore from variable name
yhk-mw 4592d12
Merge branch 'master' of https://github.com/prometheus-community/json…
yhk-mw 92f077a
Merge branch 'prometheus-community-master' into value-converter
yhk-mw 428f101
Fix formatting error from merging
yhk-mw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| --- | ||
| #the following tests use ./valueconverter.json | ||
|
|
||
| modules: | ||
| default: | ||
| metrics: | ||
| #State should be converted to 1 for the metric value | ||
| #Test uppercase key | ||
| - name: test1 | ||
| path: "{$}" | ||
| help: Testing Single Value Converter on Type Object | ||
| type: object | ||
| labels: | ||
| name: '{.name}' | ||
| values: | ||
| state: '{.state}' | ||
| valueconverter: | ||
| '{.state}': | ||
| ACTIVE: 1 | ||
|
|
||
| #State should be converted to 1 for the metric value | ||
| #Test lowercase key | ||
| - name: test2 | ||
| path: "{$}" | ||
| help: Testing Single Value Converter on Type Object | ||
| type: object | ||
| labels: | ||
| name: '{.name}' | ||
| values: | ||
| state: '{.state}' | ||
| valueconverter: | ||
| '{.state}': | ||
| active: 1 | ||
|
|
||
| #There should be two JSONs returned: a metric for 'state' with value 1, and a metric with value 12 | ||
| - name: test3 | ||
| path: "{$}" | ||
| help: Testing Multi Diff Value Converter on Type Object | ||
| type: object | ||
| labels: | ||
| name: '{.name}' | ||
| values: | ||
| state: '{.state}' | ||
| active: 12 | ||
| valueconverter: | ||
| '{.state}': | ||
| ACTIVE: 1 | ||
|
|
||
| #Nothing should be returned. This should be an error since 'state' can't be converted to an int | ||
| - name: test4 | ||
| path: "{$}" | ||
| help: Testing Value with missing conversion | ||
| type: object | ||
| labels: | ||
| name: '{.name}' | ||
| values: | ||
| state: '{.state}' | ||
|
|
||
| #Test nested JSON. It should return with both values but with 12 as the metric value | ||
| - name: test5 | ||
| path: '{.values[*]}' | ||
| help: Testing Conversion with Missing value | ||
| type: object | ||
| labels: | ||
| name: '{.name}' | ||
| values: | ||
| active: 12 | ||
| valueconverter: | ||
| '{.state}': | ||
| ACTIVE: 1 | ||
|
|
||
| #Test nested JSON. | ||
| #It should return with both values but 'state' should be converted | ||
| - name: test6 | ||
| path: '{.values[*]}' | ||
| help: Testing Value with Multiple Conversions | ||
| type: object | ||
| labels: | ||
| name: '{.name}' | ||
| values: | ||
| state: '{.state}' | ||
| valueconverter: | ||
| '{.state}': | ||
| ACTIVE: 1 | ||
| inactive: 2 | ||
|
|
||
| #Test nested JSON. | ||
| #However, it should only return with state value | ||
| #There is a missing key: 'down' in valueconverter | ||
| - name: test7 | ||
| path: '{.values[*]}' | ||
| help: Testing Value with Multiple Conversions and Missing Key, Value | ||
| type: object | ||
| labels: | ||
| name: '{.name}' | ||
| values: | ||
| state: '{.state}' | ||
| valueconverter: | ||
| '{.state}': | ||
| ACTIVE: 1 | ||
|
|
||
| #Two metrics should be returned | ||
| #State should be mapped to 1. | ||
| #ResponseCode should be 2 because it already has a value in the JSON. | ||
| - name: test8 | ||
| path: "{$}" | ||
| help: Testing Multi Diff Value Converter on Type Object | ||
| type: object | ||
| labels: | ||
| name: '{.name}' | ||
| values: | ||
| stat: '{.state}' | ||
| active: '{.responseCode}' | ||
| valueconverter: | ||
| '{.state}': | ||
| ACTIVE: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # HELP test1_state Testing Single Value Converter on Type Object | ||
| # TYPE test1_state untyped | ||
| test1_state{name="Test Converter"} 1 | ||
| # HELP test2_state Testing Single Value Converter on Type Object | ||
| # TYPE test2_state untyped | ||
| test2_state{name="Test Converter"} 1 | ||
| # HELP test3_active Testing Multi Diff Value Converter on Type Object | ||
| # TYPE test3_active untyped | ||
| test3_active{name="Test Converter"} 12 | ||
| # HELP test3_state Testing Multi Diff Value Converter on Type Object | ||
| # TYPE test3_state untyped | ||
| test3_state{name="Test Converter"} 1 | ||
| # HELP test5_active Testing Conversion with Missing value | ||
| # TYPE test5_active untyped | ||
| test5_active{name="id-A"} 12 | ||
| test5_active{name="id-B"} 12 | ||
| # HELP test6_state Testing Value with Multiple Conversions | ||
| # TYPE test6_state untyped | ||
| test6_state{name="id-A"} 1 | ||
| test6_state{name="id-B"} 2 | ||
| # HELP test7_state Testing Value with Multiple Conversions and Missing Key, Value | ||
| # TYPE test7_state untyped | ||
| test7_state{name="id-A"} 1 | ||
| # HELP test8_active Testing Multi Diff Value Converter on Type Object | ||
| # TYPE test8_active untyped | ||
| test8_active{name="Test Converter"} 2 | ||
| # HELP test8_stat Testing Multi Diff Value Converter on Type Object | ||
| # TYPE test8_stat untyped | ||
| test8_stat{name="Test Converter"} 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "name": "Test Converter", | ||
| "state": "ACTIVE", | ||
| "responseCode": 2, | ||
| "values": [ | ||
| { | ||
| "name": "id-A", | ||
| "state": "ACTIVE" | ||
| }, | ||
| { | ||
| "name": "id-B", | ||
| "state": "INACTIVE" | ||
| } | ||
| ] | ||
| } | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.