Last active
March 4, 2018 05:19
-
-
Save bmabey/d513b1bb9fb91c3dfe92d3a8270a0081 to your computer and use it in GitHub Desktop.
instaparse parser for prometheus text format exporter (text version 0.0.4)
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
(* see https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#text-format-details *) | |
statements = (type-def | help | metric)* | |
type-def = <"# TYPE "> metric-name <space> type <newline>? | |
type = #"counter|gauge|histogram|summary|untyped" | |
help = <"# HELP "> metric-name <space> docstring <newline>? | |
metric = metric-name labels? <space> value (<space> timestamp)? <newline>? | |
labels = <'{'> label-name label-value {<','> label-name label-value} <','>? <'}'> | |
(* the below doesn't take into account escaping but probably not an issue for our use case *) | |
label-value=<'="'>#'\w+'<'"'> | |
value = #"[0-9]+\.[0-9]" | |
timestamp = #'[0-9]+' | |
(* via https://github.com/prometheus/client_java/issues/28 *) | |
metric-name = #'[a-zA-Z_:]([a-zA-Z0-9_:])*' | |
label-name = #'[a-zA-Z_]([a-zA-Z0-9_])*' | |
newline = #'\n' | |
space = ' ' | |
docstring=<string> | |
string= #'[^\n]*' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment