# Collectd index name

**URL:** <https://discuss.elastic.co/t/collectd-index-name/65386>\
**Category:** Logstash\
**Created:** [November 8, 2016, 6:21pm UTC](https://discuss.elastic.co/t/collectd-index-name/65386 "2016-11-08T18:21:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kernel\_Panic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kernel_panic/32/12294_2.png) [@Kernel\_Panic](https://discuss.elastic.co/u/Kernel_Panic)\
**Post date:** [November 8, 2016, 6:21pm UTC](https://discuss.elastic.co/t/collectd-index-name/65386/1 "2016-11-08T18:21:38Z")

</div>

Hi there guys

I'm configuring collectd to gather info from my docker containers, so far so good, but I'd like the to have a descriptive index name, now it's called like bellow, which was created automatically, I'd like to have something like collectd-DATE-FORMAT

yellow open %{[@metadata][beat]}-2016.11.08 5 1 86550 0 10.9mb 10.9mb

I created an input file like this:

```
    input {
      udp {
        port => 25826
        buffer_size => 1452
        codec => collectd { }
      }
    }

```

and got an output like this which works with filebeat and metricbeat:

cat 30-output.conf

```
output {
  elasticsearch {
    hosts => ["server-name"]
    sniffing => true
    manage_template => false
    index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
    document_type => "%{[@metadata][type]}"
  }
}

```

What am I missing  
Thanks in advance  
Regards

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 8, 2016, 7:55pm UTC](https://discuss.elastic.co/t/collectd-index-name/65386/2 "2016-11-08T19:55:41Z")

</div>

If you set a type for your collectd event (e.g. `type => "collectd"` in your input declaration) you can add a conditional in your output block to choose between two elasticsearch output. One if it's a collectd message and another one for Beats messages. Or, name the index after the beat name if available and otherwise store the events elsewhere:

```nohighlight
output {
  if [@metadata][beat] {
    elasticsearch {
      hosts => ["server-name"]
      sniffing => true
      manage_template => false
      index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
      document_type => "%{[@metadata][type]}"
    }
  } else {
    elasticsearch {
      hosts => ["server-name"]
      sniffing => true
      manage_template => false
      index => "collectd-%{+YYYY.MM.dd}"
      document_type => "collectd"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Kernel\_Panic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kernel_panic/32/12294_2.png) [@Kernel\_Panic](https://discuss.elastic.co/u/Kernel_Panic)\
**Post date:** [November 8, 2016, 8:02pm UTC](https://discuss.elastic.co/t/collectd-index-name/65386/3 "2016-11-08T20:02:25Z")

</div>

Thank you very much, very kind of U.  
Regards

---

<div class="post-metadata">

**Author:** ![Kernel\_Panic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kernel_panic/32/12294_2.png) [@Kernel\_Panic](https://discuss.elastic.co/u/Kernel_Panic)\
**Post date:** [November 8, 2016, 8:47pm UTC](https://discuss.elastic.co/t/collectd-index-name/65386/4 "2016-11-08T20:47:04Z")

</div>

> [@magnusbaeck](#):
>
> output {  
> if [@metadata][beat] {{  
> elasticsearch {  
> hosts =\> ["server-name"]  
> sniffing =\> true  
> manage\_template =\> false  
> index =\> "%{[@metadata][beat]}-%{+YYYY.MM.dd}"  
> document\_type =\> "%{[@metadata][type]}"  
> }  
> } else {  
> elasticsearch {  
> hosts =\> ["server-name"]  
> sniffing =\> true  
> manage\_template =\> false  
> index =\> "collectd-%{+YYYY.MM.dd}"  
> document\_type =\> "collectd"  
> }  
> }  
> }

Hi,  
I get this error when starting logstash, just copy/paste the example above, only replaced with the correct server name.

{:timestamp=\>"2016-11-08T14:45:24.664000-0600", :message=\>"Error: Expected one of #, if, ", ', } at line 43, column 25 (byte 985) after output {\n if [@metadata][beat] {", :level=\>:error}

Thank you!

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 8, 2016, 9:39pm UTC](https://discuss.elastic.co/t/collectd-index-name/65386/5 "2016-11-08T21:39:28Z")

</div>

There's a double opening brace on the second line. I've corrected the previously posted snippet.

---

<div class="post-metadata">

**Author:** ![Kernel\_Panic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kernel_panic/32/12294_2.png) [@Kernel\_Panic](https://discuss.elastic.co/u/Kernel_Panic)\
**Post date:** [November 8, 2016, 11:35pm UTC](https://discuss.elastic.co/t/collectd-index-name/65386/6 "2016-11-08T23:35:51Z")

</div>

Lotta thanks!!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 6, 2016, 11:36pm UTC](https://discuss.elastic.co/t/collectd-index-name/65386/7 "2016-12-06T23:36:02Z")

</div>

Closed on December 6, 2016, 11:36pm UTC

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