{"action":"created","issue":{"url":"https://api.github.com/repos/influxdata/kapacitor/issues/1589","repository_url":"https://api.github.com/repos/influxdata/kapacitor","labels_url":"https://api.github.com/repos/influxdata/kapacitor/issues/1589/labels{/name}","comments_url":"https://api.github.com/repos/influxdata/kapacitor/issues/1589/comments","events_url":"https://api.github.com/repos/influxdata/kapacitor/issues/1589/events","html_url":"https://github.com/influxdata/kapacitor/issues/1589","id":261146012,"node_id":"MDU6SXNzdWUyNjExNDYwMTI=","number":1589,"title":"Custom JSON output for Alert Post and HttpPost Nodes","user":{"login":"dp1140a","id":5685054,"node_id":"MDQ6VXNlcjU2ODUwNTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/5685054?v=4","gravatar_id":"","url":"https://api.github.com/users/dp1140a","html_url":"https://github.com/dp1140a","followers_url":"https://api.github.com/users/dp1140a/followers","following_url":"https://api.github.com/users/dp1140a/following{/other_user}","gists_url":"https://api.github.com/users/dp1140a/gists{/gist_id}","starred_url":"https://api.github.com/users/dp1140a/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dp1140a/subscriptions","organizations_url":"https://api.github.com/users/dp1140a/orgs","repos_url":"https://api.github.com/users/dp1140a/repos","events_url":"https://api.github.com/users/dp1140a/events{/privacy}","received_events_url":"https://api.github.com/users/dp1140a/received_events","type":"User","site_admin":false},"labels":[{"id":254703702,"node_id":"MDU6TGFiZWwyNTQ3MDM3MDI=","url":"https://api.github.com/repos/influxdata/kapacitor/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":434381276,"node_id":"MDU6TGFiZWw0MzQzODEyNzY=","url":"https://api.github.com/repos/influxdata/kapacitor/labels/new-feature","name":"new-feature","color":"0052cc","default":false},{"id":526041611,"node_id":"MDU6TGFiZWw1MjYwNDE2MTE=","url":"https://api.github.com/repos/influxdata/kapacitor/labels/pm/extensibility","name":"pm/extensibility","color":"c2e0c6","default":false}],"state":"closed","locked":false,"assignee":{"login":"rbetts","id":158141,"node_id":"MDQ6VXNlcjE1ODE0MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/158141?v=4","gravatar_id":"","url":"https://api.github.com/users/rbetts","html_url":"https://github.com/rbetts","followers_url":"https://api.github.com/users/rbetts/followers","following_url":"https://api.github.com/users/rbetts/following{/other_user}","gists_url":"https://api.github.com/users/rbetts/gists{/gist_id}","starred_url":"https://api.github.com/users/rbetts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbetts/subscriptions","organizations_url":"https://api.github.com/users/rbetts/orgs","repos_url":"https://api.github.com/users/rbetts/repos","events_url":"https://api.github.com/users/rbetts/events{/privacy}","received_events_url":"https://api.github.com/users/rbetts/received_events","type":"User","site_admin":false},"assignees":[{"login":"rbetts","id":158141,"node_id":"MDQ6VXNlcjE1ODE0MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/158141?v=4","gravatar_id":"","url":"https://api.github.com/users/rbetts","html_url":"https://github.com/rbetts","followers_url":"https://api.github.com/users/rbetts/followers","following_url":"https://api.github.com/users/rbetts/following{/other_user}","gists_url":"https://api.github.com/users/rbetts/gists{/gist_id}","starred_url":"https://api.github.com/users/rbetts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbetts/subscriptions","organizations_url":"https://api.github.com/users/rbetts/orgs","repos_url":"https://api.github.com/users/rbetts/repos","events_url":"https://api.github.com/users/rbetts/events{/privacy}","received_events_url":"https://api.github.com/users/rbetts/received_events","type":"User","site_admin":false},{"login":"nathanielc","id":3771906,"node_id":"MDQ6VXNlcjM3NzE5MDY=","avatar_url":"https://avatars3.githubusercontent.com/u/3771906?v=4","gravatar_id":"","url":"https://api.github.com/users/nathanielc","html_url":"https://github.com/nathanielc","followers_url":"https://api.github.com/users/nathanielc/followers","following_url":"https://api.github.com/users/nathanielc/following{/other_user}","gists_url":"https://api.github.com/users/nathanielc/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielc/subscriptions","organizations_url":"https://api.github.com/users/nathanielc/orgs","repos_url":"https://api.github.com/users/nathanielc/repos","events_url":"https://api.github.com/users/nathanielc/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielc/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/influxdata/kapacitor/milestones/13","html_url":"https://github.com/influxdata/kapacitor/milestone/13","labels_url":"https://api.github.com/repos/influxdata/kapacitor/milestones/13/labels","id":2965028,"node_id":"MDk6TWlsZXN0b25lMjk2NTAyOA==","number":13,"title":"1.5.0","description":null,"creator":{"login":"rbetts","id":158141,"node_id":"MDQ6VXNlcjE1ODE0MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/158141?v=4","gravatar_id":"","url":"https://api.github.com/users/rbetts","html_url":"https://github.com/rbetts","followers_url":"https://api.github.com/users/rbetts/followers","following_url":"https://api.github.com/users/rbetts/following{/other_user}","gists_url":"https://api.github.com/users/rbetts/gists{/gist_id}","starred_url":"https://api.github.com/users/rbetts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbetts/subscriptions","organizations_url":"https://api.github.com/users/rbetts/orgs","repos_url":"https://api.github.com/users/rbetts/repos","events_url":"https://api.github.com/users/rbetts/events{/privacy}","received_events_url":"https://api.github.com/users/rbetts/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":19,"state":"closed","created_at":"2017-12-07T17:07:40Z","updated_at":"2018-10-29T18:01:24Z","due_on":null,"closed_at":"2018-10-29T18:01:24Z"},"comments":15,"created_at":"2017-09-27T23:13:40Z","updated_at":"2018-11-07T16:48:21Z","closed_at":"2017-12-07T21:55:08Z","author_association":"NONE","body":"This is a feature request for the ability to specify custom JSON output for the Alert Post and HttpPost nodes.  As it stands now there is no control over how the JSON looks and adding additional elements to it is not a trivial task.\r\n\r\nIn thinking how this might be implemented I could see a parameter that might point to a template file that could perform the mapping:\r\n\r\n.template(String template, Boolean appendUnusedValues)\r\ntemplateFIle -- The path and name pf the template file or a string with the template definition.  This would allow you to specify the template in the TICK script as a var or separately as a file\r\nappendUnusedValues -- If true would append any remaining tags or fields to the end of the json.  This would provide the ability to transform certain tags or fields while retaining many of the original tags and fields.  If false only the tag or field values specified in the template will be in the output json\r\n\r\nstream\r\n         |httpPost()\r\n            .template('myTemplate.tmpl', true)\r\n            .endpoint('example')\r\n            \r\nWhere the template file might look like:\r\n{\r\n   \"myParam1\": {{tag.tagName}},\r\n   \"myParam2\": {{field.fieldName}}\r\n}\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/influxdata/kapacitor/issues/comments/436693286","html_url":"https://github.com/influxdata/kapacitor/issues/1589#issuecomment-436693286","issue_url":"https://api.github.com/repos/influxdata/kapacitor/issues/1589","id":436693286,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNjY5MzI4Ng==","user":{"login":"arturo-mondelo","id":11028281,"node_id":"MDQ6VXNlcjExMDI4Mjgx","avatar_url":"https://avatars0.githubusercontent.com/u/11028281?v=4","gravatar_id":"","url":"https://api.github.com/users/arturo-mondelo","html_url":"https://github.com/arturo-mondelo","followers_url":"https://api.github.com/users/arturo-mondelo/followers","following_url":"https://api.github.com/users/arturo-mondelo/following{/other_user}","gists_url":"https://api.github.com/users/arturo-mondelo/gists{/gist_id}","starred_url":"https://api.github.com/users/arturo-mondelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arturo-mondelo/subscriptions","organizations_url":"https://api.github.com/users/arturo-mondelo/orgs","repos_url":"https://api.github.com/users/arturo-mondelo/repos","events_url":"https://api.github.com/users/arturo-mondelo/events{/privacy}","received_events_url":"https://api.github.com/users/arturo-mondelo/received_events","type":"User","site_admin":false},"created_at":"2018-11-07T16:48:21Z","updated_at":"2018-11-07T16:48:21Z","author_association":"NONE","body":"This is my chronograf generated tick script (in our environments use custom ones). But, for this test, it works just fine:\r\n\r\nvar db = 'telegraf'\r\n\r\nvar rp = 'autogen'\r\n\r\nvar measurement = 'cpu'\r\n\r\nvar groupBy = ['host']\r\n\r\nvar whereFilter = lambda: TRUE\r\n\r\nvar name = 'use cpu'\r\n\r\nvar idVar = name + ':{{.Group}}'\r\n\r\nvar message = ' {{.ID}} {{.Name}} {{.TaskName}} {{.Group}} {{ index .Fields \"value\" }}'\r\n\r\nvar idTag = 'alertID'\r\n\r\nvar levelTag = 'level'\r\n\r\nvar messageField = 'message'\r\n\r\nvar durationField = 'duration'\r\n\r\nvar outputDB = 'chronograf'\r\n\r\nvar outputRP = 'autogen'\r\n\r\nvar outputMeasurement = 'alerts'\r\n\r\nvar triggerType = 'threshold'\r\n\r\nvar details = 'Valor {{ index .Fields \"value\" }}'\r\n\r\nvar crit = 20\r\n\r\nvar data = stream\r\n    |from()\r\n        .database(db)\r\n        .retentionPolicy(rp)\r\n        .measurement(measurement)\r\n        .groupBy(groupBy)\r\n        .where(whereFilter)\r\n    |eval(lambda: \"usage_user\")\r\n        .as('value')\r\n\r\nvar trigger = data\r\n    |alert()\r\n        .crit(lambda: \"value\" > crit)\r\n        .message(message)\r\n        .id(idVar)\r\n        .idTag(idTag)\r\n        .levelTag(levelTag)\r\n        .messageField(messageField)\r\n        .durationField(durationField)\r\n        .details(details)\r\n        .post()\r\n        .endpoint('ejemplo')\r\n\r\ntrigger\r\n    |eval(lambda: float(\"value\"))\r\n        .as('value')\r\n        .keep()\r\n    |influxDBOut()\r\n        .create()\r\n        .database(outputDB)\r\n        .retentionPolicy(outputRP)\r\n        .measurement(outputMeasurement)\r\n        .tag('alertName', name)\r\n        .tag('triggerType', triggerType)\r\n\r\ntrigger\r\n    |httpOut('output')"}}
{"actor":{"display_login":"arturo-mondelo"}}