# Add Dynamic Tags Based on Field

**URL:** <https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875>\
**Category:** Telegraf\
**Tags:** telegraf\
**Created:** [September 7, 2020, 6:34am UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875 "2020-09-07T06:34:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mert](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mert/32/5152_2.png) [@Mert](https://community.influxdata.com/u/Mert)\
**Post date:** [September 7, 2020, 6:34am UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875/1 "2020-09-07T06:34:58Z")

</div>

Hi,

Problem: I’m using telegraf’s win\_services plugin which has field “state” with values “1 2 3 4 5 6 7”. I want to add text explanation of this numbers as a tag. Example: `if 4 > "Running" if 1 > "Stopped"`

Can you help me to with an example config? I searched this question and found enum processor but I’m not sure if it’s the solution.

1. As far as I understand, enum works across the config file. I need it for only “win\_services” measurement.
2. I need to create tags from field values.

---

<div class="post-metadata">

**Author:** ![mhall119](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mhall119/32/3898_2.png) [@mhall119](https://community.influxdata.com/u/mhall119)\
**Post date:** [September 8, 2020, 4:41pm UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875/2 "2020-09-08T16:41:13Z")

</div>

You could use the `enum` processor, I think something like this might do what you want:

> [[processors.enum]]  
> [[processors.enum.mapping]]  
> namepass = “win\_services”  
> field = “state”  
> dest = “state\_label”  
> [processors.enum.mapping.value\_mappings]  
> 1 = “Stopped”  
> 4 = “Running”

The `namepass` parameter will limit the plugin to only run against the `win_services` measurement.

You can also convert your `state` field into a tag in Telegraf with the `converter` plugin:

> [processors.converter.fields]  
> tag = [“state”]

Then in your Flux query you can change the value from a number to a human-readable label.

---

<div class="post-metadata">

**Author:** ![Casey](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@Casey](https://community.influxdata.com/u/Casey)\
**Post date:** [September 8, 2020, 5:33pm UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875/3 "2020-09-08T17:33:40Z")

</div>

Very cool @mhall119 !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/2/f/2feb065bdfd5e4b7728243aa3b9192ad3e8447c1.png) [@system](https://community.influxdata.com/u/system)\
**Post date:** [September 9, 2020, 10:45am UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875/4 "2020-09-09T10:45:38Z")

</div>

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![mhall119](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mhall119/32/3898_2.png) [@mhall119](https://community.influxdata.com/u/mhall119)\
**Post date:** [September 9, 2020, 5:10pm UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875/5 "2020-09-09T17:10:09Z")

</div>



---

<div class="post-metadata">

**Author:** ![Mert](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mert/32/5152_2.png) [@Mert](https://community.influxdata.com/u/Mert)\
**Post date:** [September 9, 2020, 5:31pm UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875/6 "2020-09-09T17:31:53Z")

</div>

First of all thanks for your reply.

I wonder if I can set “state\_label” as a tag instead of field while the “state” is field.  
I’ve tried to combine “converter” with “enum” but no luck. Generated “state\_label” field with enum then tried to convert it into a tag with “converter” but telegraf telegraf doesn’t run processor plugins in the order of their place in the config file. I’m not sure if I can create a pipeline in telegraf or is there a simpler way?

I don’t use flux for now. So, I want to add the tag into the data points itself.

---

<div class="post-metadata">

**Author:** ![mhall119](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mhall119/32/3898_2.png) [@mhall119](https://community.influxdata.com/u/mhall119)\
**Post date:** [September 9, 2020, 6:23pm UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875/7 "2020-09-09T18:23:07Z")

</div>

You can force the order that Processors are run by giving them an `order = #` parameter: [telegraf/CONFIGURATION.md at master · influxdata/telegraf · GitHub](https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#processor-plugins)

---

<div class="post-metadata">

**Author:** ![Mert](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mert/32/5152_2.png) [@Mert](https://community.influxdata.com/u/Mert)\
**Post date:** [September 9, 2020, 7:18pm UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875/8 "2020-09-09T19:18:16Z")

</div>

Cool Thanks!

```auto
[[processors.enum]]
  namepass = "win_services"
  order = 1
  [[processors.enum.mapping]]
    field = "state"
    dest = "state_label"
    [processors.enum.mapping.value_mappings]
      1 = "Stopped"
      4 = "Running"
      2 = "Start Pending"
      3 = "Stop Pending" 
      5 = "Continue Pending"
      6 = "Pause Pending"
      7 = "Paused"

[[processors.converter]]
  namepass = "win_services"
  order = 2
  [processors.converter.fields]
    tag = ["state_label"]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/2/f/2feb065bdfd5e4b7728243aa3b9192ad3e8447c1.png) [@system](https://community.influxdata.com/u/system)\
**Post date:** [September 10, 2020, 7:18am UTC](https://community.influxdata.com/t/add-dynamic-tags-based-on-field/15875/9 "2020-09-10T07:18:19Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
