File tree Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,45 @@ _filter_opentelemetry_labels()
5656 # end
5757}
5858
59+ _reorder_labels ()
60+ {
61+ awk '
62+ /^[^#].*{.*=.*}/ {
63+ match($0, /^([^{]+){([^}]+)}(.*)$/, a)
64+ metric = a[1]
65+ labels_str = a[2]
66+ rest = a[3]
67+
68+ delete labels
69+ n = split(labels_str, pairs, ",")
70+ for (i = 1; i <= n; i++) {
71+ match(pairs[i], /^([^=]+)=(.+)$/, kv)
72+ key = kv[1]
73+ value = kv[2]
74+ labels[key] = value
75+ }
76+
77+ order = "url agent hostname domainname machineid source my_sum_attribute"
78+ split(order, order_arr, " ")
79+
80+ output = metric "{"
81+ first = 1
82+ for (i = 1; i <= length(order_arr); i++) {
83+ key = order_arr[i]
84+ if (key in labels) {
85+ if (!first) output = output ","
86+ output = output key "=" labels[key]
87+ first = 0
88+ }
89+ }
90+ output = output "}" rest
91+ print output
92+ next
93+ }
94+ {print}
95+ '
96+ }
97+
5998need_restore=true
6099_prepare_pmda opentelemetry
61100trap " _cleanup; exit \$ status" 0 1 2 3 15
83122
84123echo ; echo === /metrics webapi listing. The instname label should appear only once.
85124curl -Gs ' http://localhost:44322/metrics?names=opentelemetry.duplicate.somemetric' \
86- | _filter_opentelemetry_labels
125+ | _filter_opentelemetry_labels | _reorder_labels
87126
88127echo ; echo === verify metric name validity using pminfo
89128pminfo -v opentelemetry
You can’t perform that action at this time.
0 commit comments