Splunk Search

How to rename multiple fields in a chart?

zhatsispgx
Path Finder

When i run the following query, my legend has the values as values(fieldname):

index=main source=daily_report sourcetype=ironport_stats | chart values(malicious_url),values(detected_virus) over insert_date by server

How would I rename the values fields so they show up as what I want in the legend of the graph?

Thanks in advance!

0 Karma

somesoni2
Revered Legend

If you use column-split options with charting commands like chart/timechart (over field by field for chart and by field for timechart), it'll creates columns which include the values of the by clause field.

E.g. ..|chart count over field1 by field2 will give columns field1, field2value1 field2value2.....

If you're using multiple aggregation, Splunk can't differentiate them with just the field1value, so it appends the aggregation column names as well.

E.g. ..|chart count dc(field3) over field1 by field2 will give columns field1, count:field2value1 count:field2value2... dc(field3):field2value1, dc(field3):field2value2.....

I would rename aggregation field within chart command itself to give a proper name so that chart generates series with proper names. E.g. ..|chart count dc(field3) as label over field1 by field2 will give columns field1, count:field2value1 count:field2value2... label:field2value1, label:field2value2.....

What is the field name that you expect to come? Consider using stats instead of chart.

0 Karma

mydog8it
Builder

Try:
index=main source=daily_report sourcetype=ironport_stats | chart values(malicious_url),values(detected_virus) over insert_date by server | rename values(malicious_url) as malicious_url values(detected_virus) as detected_virus

0 Karma

zhatsispgx
Path Finder

this didn't work. the legend still shows:

values(malicious_url): mail1
values(malicious_url): mail2

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Catalog Is Now Generally Available on Splunk Cloud Platform

A Unified View of Your Data  Security logs, application events, business data, and historical telemetry often ...

Developer Spotlight with Eduard Lekanne

From Network Engineer to Building Agentic AI for Splunk Eduard Lekanne has been architecting technology ...

From Data Landing to Insight

Search Across More of Your Data Ecosystem The data you need may live in Splunk, high-volume machine data, ...