# How to filter the information in the Kibana Watcher attachment?

**URL:** <https://discuss.elastic.co/t/how-to-filter-the-information-in-the-kibana-watcher-attachment/170550>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-reporting, elastic-stack-alerting\
**Created:** [March 1, 2019, 7:08pm UTC](https://discuss.elastic.co/t/how-to-filter-the-information-in-the-kibana-watcher-attachment/170550 "2019-03-01T19:08:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrGetfit1234](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@MrGetfit1234](https://discuss.elastic.co/u/MrGetfit1234)\
**Post date:** [March 1, 2019, 7:08pm UTC](https://discuss.elastic.co/t/how-to-filter-the-information-in-the-kibana-watcher-attachment/170550/1 "2019-03-01T19:08:33Z")

</div>

hi,

I am using a Kibana watcher to send an email with attachments. The attachments will be of ".csv "format. I will need only two columns in the csv( list of ip's) followed by number of logs collected per ip.

# Here is my code so far:

```
   {
  "trigger": {
    "schedule": {
      "interval": "10h"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "custom-*"
        ],
        "types": [],
        "body": {
          "size": 0,
          "query": {
            "bool": {
              "must": [
                {
                  "range": {
                    "@timestamp": {
                      "gte": "now-30m"
                    }
                  }
                }
              ]
            }
          },
          "aggs": {
            "source_ip": {
              "terms": {
                "field": "SOURCEIP",
                "size": 2000
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "always": {}
  },
  "actions": {
    "send_email": {
      "transform": {
        "script": {
          "source": "return ctx.payload.hits",
          "lang": "painless"
        }
      },
      "email": {
        "profile": "standard",
        "attachments": {
          "data.csv": {
            "data": {
              "format": "yaml"
            }
          }
        },
        "to": [
          "myself@emailaddress.com"
        ],
        "subject": "TestEmail",
        "body": {
          "html": "testEmail "
        }
      }
    }
  }
}

```

How do I go about formatting the two columns in my csv attachment?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 20, 2019, 8:58am UTC](https://discuss.elastic.co/t/how-to-filter-the-information-in-the-kibana-watcher-attachment/170550/2 "2019-03-20T08:58:05Z")

</div>

Hey,

right now it is not possible to create a CSV based attachment via the email attachment. you can choose YAML or JSON (you chose YAML in your example).

Hope this helps!

--Alex

---

<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:** [April 17, 2019, 8:58am UTC](https://discuss.elastic.co/t/how-to-filter-the-information-in-the-kibana-watcher-attachment/170550/3 "2019-04-17T08:58:10Z")

</div>

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