Convert influxdb field into tag value


Hi all ,
I am using custom log parser to parse nginx logs from telegraf to influx db for plotting grafana dashboard , I am getting response time , response code for different api in nginx_access_log table from influxdb . Now , I want to plot response time with all api in one graph where want to put api name as tag value .
Can it possible by any mean as in nginx_access_log , I am getting api name as field but want to convert api name into tag value .


It sounds like you should be storing the API name as a tag from the very beginning; is there a reason you’re currently storing that data as a field?

It is possible to use the Logparser plugin to create tag values by adding a modifier to your Grok parser, as described in the documentation.


Thanks for reply , how can i store API name as a tag from beginning ,pls suggest
And , i also used Grok parser and used custom pattern inside [inputs.logparser.grok] plugin ,
This is my grok , where only host and path of nginx log (i.e. /var/log/nginx/access.loog)getting as tag .
%{IP:client} %{HOSTNAME:host} %{NGUSER:ident} %{NGUSER:auth} [%{HTTPDATE:timestamp}] “%{WORD:method} %{URIPATHPARAM:request} HTTP/%{NUMBER:version}” %{NUMBER:resp_code} %{NUMBER:bytessent} “%{NGUSER:referer}” “%{GREEDYDATA:user_agent}” “%{IP:forward_for}” %{IP:upstream_add}:7005 %{NUMBER:upstream_status} %{NUMBER:requesttime} %{NUMBER:upstream_response}


Please read the documentation in the link I provided.

It describes the format for Telegraf grok patterns, including the concept of modifiers. One of the modifiers listed is “tag (converts a field to a tag)”.


Thanks lot studied documents, its really worked for me

1 Like

Hi ,

Can you help me on this also , I used grok pattern in telegraf config file to take out nginx data , now using telegraf and influxdb data source I created a grafana dashboard of nginx response for different api but my grafana is now very slow after using grok pattern , when plotted only system matrix , grafana was faster .
Pls help to do to any tuning regarding this