Capitalize the first letter of a field display name

Hi all!

I’d like to capitalize the first letter of a field display name in Grafana (e.g. “fieldname” → “Fieldname”).

I tried with the “Rename by regex” transformation, using the special regex character \u, that converts the next character to upper case:

Match: (.*)
Replace: \u$1

But the special character does not get recognized and the name becomes “\ufieldname”.

I know that I can use overrides to accomplish that, but I would like to know if there’s a more automated way of doing this.

Thanks a lot!

hello,
what is your datasource ? could you do it in your query ?
ideally you want transform your data before visualisation part,
if it’s SQL you can use some case and upper fonction i think

I’m using Grafana Live Measurements, so no SQL involved, and no possibility to tweak the query.

Hi,
I don’t think uppercase conversion is possible like this. AFAIK, the replace part only accepts found capture groups and fix literals.
The only solution I can think of is to create 26 “Rename by regex” transformations, one for each letter:

Match: a(.*)
Replace: A$1

Match: b(.*)
Replace: B$1

Match: c(.*)
Replace: C$1

Match: z(.*)
Replace: Z$1

Best regards

Tricky but working. Thanks!