Hi All,
I created a watcher with an email action to generate a dashboard pdf and send that out to an email address. In principal this works however the pdf cannot be opened with the error:
Adobe Acrobat Reader could not open 'dashboard.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).
The watcher config I use is the following.
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"clog-*"
],
"types": [
"logs"
],
"body": {
"size": 0,
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "program:GW AND EnvID:p-xxxxn AND action:P6_ACCEPT_DEFAULT AND _exists_:hdr_subject AND cm_score: [0 TO 90]",
"analyze_wildcard": true
}
},
{
"range": {
"@timestamp": {
"gte": "now-5m",
"lte": "now"
}
}
}
],
"must_not": []
}
},
"aggs": {
"subjects": {
"terms": {
"field": "hdr_subject.keyword",
"min_doc_count": 10,
"size": 5,
"order": {
"_count": "desc"
}
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "if (ctx.payload.hits.total < 1) return false; for(int i=0; i < ctx.payload.aggregations.subjects.buckets.size(); i++) if (ctx.payload.aggregations.subjects.buckets[i].doc_count > 10) return true",
"lang": "painless"
}
},
"actions": {
"standard_account": {
"throttle_period_in_millis": 900000,
"email": {
"profile": "standard",
"attachments": {
"dashboard.pdf": {
"http": {
"request": {
"scheme": "http",
"host": "my.kibana.host",
"port": 5601,
"method": "post",
"path": "/api/reporting/generate/dashboard/AV9R_W0QON_pt8a4d3oh&sync",
"params": {},
"headers": {
"kbn-xsrf": "reporting"
},
"auth": {
"basic": {
"username": "elastic"
}
},
"read_timeout_millis": 300000
},
"content_type": "application/pdf"
}
}
},
"priority": "high",
"to": [
"destination@example.com"
],
"subject": "Possible spam run detected (TEST).",
"body": {
"text": "Possible spam run detected. Encountered {{ctx.payload.hits.total}} subjects in 5 minutes, see attached data"
}
}
}
}
}
If I generate the report from kibana it works fine.
Is there something else I need to set to generate a correct pdf?