I have configured a variable for my Grafana dashboard. When the content of the variable is a simple string (e.g. “httpbin”), I can use it without any problems in the chart.
But as soon as the value contain any special characters like a space (e.g. “httpbin rate limiting”) or a minus (e.g. “httpbin-rate-limiting”), I get a parsing error in all the charts using the variable.
Error: bad_data: invalid parameter "query": 1:16: parse error: unexpected <op:-> in grouping opts, expected "," or ")"
Here is the example for a query using the variable:
sum by ($tykapiname) (
rate(calls{span_kind="SPAN_KIND_SERVER"}[1m])
)
How can I work with variable containing special characters?
I don’t know. You are asking out of blue and you don’t show what you are doing.
IMHO it looks like your metric generation is based on traces. So why you don’t utilise metric-generator, maybe metricsgenerationprocessor. Some trace storages have query languages (e.g. Lightstep UQL), which can create metric from the traces on the fly, so you need generate metric. Why you are using custom recording rule?
yes, you are right, that wasn’t very clear Sorry for that!
I’m using OpenTelemetry collector with the span metrics connector to generate the data from the OTel traces. Looks like metricsgenerationprocessor might work. I will give it a try.