Created
March 19, 2019 21:37
-
-
Save tzz/de12b2e188dea89cb0aafb18d1b121ad to your computer and use it in GitHub Desktop.
Chef inventory to Prometheus conversion example
This file contains 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
#!/usr/bin/jq -Sf | |
def chef_fields: | |
# special field adjustments go here | |
. | |
; | |
.rows| | |
map(select(.name)) | sort_by(.name) | | |
map(chef_fields | | |
[ | |
.automatic, | |
.automatic.dmi, | |
. # the current data | |
] | add | | |
{ | |
labels: | |
{ | |
kernel_release: .kernel.release, | |
os, | |
os_version, | |
platform, | |
platform_version, | |
platform_family, | |
}, | |
targets: ["\(.name):9100"] | |
# remove all empty or null labels | |
} | delpaths([path(.labels[]| select(. == "" or . == null))]) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment