Hi Matthew,
I think you are asking for a way to include the hostname in the field names... I would think there's a better way to do that on the fly rather than trying to extract a tonne of fields with the hostname hard coded...that makes future homework as servers are added/decommissioned... who wants to miss monitoring on the new server because poor overworked Matthew forgot to add the new server to the list...
What about something like this:
start with this as a set of base data to illustrate the point:
| makeresults | eval data="1507063392.123,was01,17,18,19,20|1507063394.345,was01,21,22,23,24|1507063396.567,was02,25,26,27,28"
| makemv delim="|" data
| mvexpand data
| rex field=data "^(?<_time>[^\,]+)\,(?<host>[^\,]+)\,(?<datapoint1>\d+)\,(?<datapoint2>\d+)\,(?<datapoint3>\d+)\,(?<datapoint4>\d+)"
| table _time host datapoint*
so i have multiple data points for each host... like so:
_time host datapoint1 datapoint2 datapoint3 datapoint4
2017-10-03 16:43:12.123 was01 17 18 19 20
2017-10-03 16:43:14.345 was01 21 22 23 24
2017-10-03 16:43:16.567 was02 25 26 27 28
From your question, I read that you want to get each datapoint1 value to be hostname-datapoint1
So to make that happen, do this:
| makeresults | eval data="1507063392.123,was01,17,18,19,20|1507063394.345,was01,21,22,23,24|1507063396.567,was02,25,26,27,28"
| makemv delim="|" data
| mvexpand data
| rex field=data "^(?<_time>[^\,]+)\,(?<host>[^\,]+)\,(?<datapoint1>\d+)\,(?<datapoint2>\d+)\,(?<datapoint3>\d+)\,(?<datapoint4>\d+)"
| table _time host datapoint*
| eval measurename=host+"-datapoint1"
| fields + _time measurename datapoint1
| chart avg(datapoint1) by measurename
Which outputs...:
measurename AVG
---------------- ---
was01-datapoint1 19
was02-datapoint1 25
... View more