Summing all fields matching certain pattern

So I would need to sum all fields matching a pattern. So for eg. I have fields apples.sanfrancisco: 10, apples.newyork: 15 and apples.miami: 100 and I would like to sum all these together with the pattern apples.*, so apples.*: 125 but this does not work. How could this be done? I’m using elasticsearch.

THANK YOU!!

~ the grafana team

Hi @pyttei ,

I think this is possible by using the Transform “Add field from calculation”. Then select the tables you like to add and use the Math operator (e.g. Sum) to get the final result in the form of a new table.

Please have a look at the attached screenshot for reference.

Hope it helps.

1 Like

Hi @usman.ahmad ,
I have explored this option but unfortunately this is not feasable for my situation since the fields that come from the data are not known/there are too many of them so I can’t possibly manually do anything like this. The only thing I could use is the pattern they come is at it stays the same.

Hi @pyttei

Have you also looked at the Regex option in the Transformation i.e.

If not then please share more details (e.g. screenshots, or maybe a small screencast) so that the community might be able to help you out.