Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables not being printed out correctly on Alerta integration #306

Closed
skylenet opened this issue Mar 10, 2016 · 2 comments
Closed

Variables not being printed out correctly on Alerta integration #306

skylenet opened this issue Mar 10, 2016 · 2 comments
Milestone

Comments

@skylenet
Copy link

I have the following .tick script :

stream
  .from()
    .measurement('cpu')
    .where(lambda: "cpu" == 'cpu-total')
  .groupBy('host', 'cpu')
  .window()
    .period(10s)
    .every(10s)
  .mapReduce(influxql.mean('usage_idle'))
  .eval(lambda: 100.0 - "mean")
    .as('used')
  .alert()
    .id('kapacitor/{{ .Name }}/{{ .Group }}')
    .message('<b>{{ .Name }}</b>: Group: <b>{{ .Group }}</b> Usage: <b>{{ index .Fields "used" | printf "%0.0f" }}%</b>')
    .stateChangesOnly()
    .warn(lambda: "used" > 80.0)
    .crit(lambda: "used" > 90.0)
    .alerta()
      .resource('{{ .ID }}')
      .event('{{ .Name }}')
      .value('{{ index .Fields "used" | printf "%0.0f" }}')
    .log('/tmp/alerts_cpu.log')
    .hipChat() 

The alert does go to Alerta but the resource,event and value fields are not printing out the correct values. They simple print out "{{ .ID }}" as a string.

Example response from Alerta:

[cpu_alert:alert6] 2016/03/10 14:30:39 E! failed to send alert data to Alerta: failed to understand Alerta response: {
  "status": "ok",
  "id": "b95eff87-b921-49e5-95de-d7a016511f65",
  "alert": {
    "origin": "kapacitor",
    "text": "<b>cpu</b>: Group: <b>cpu=cpu-total,host=a-host-001,</b> Usage: <b>15%</b>",
    "lastReceiveTime": "2016-03-10T14:30:39.909Z",
    "receiveTime": "2016-03-10T14:30:39.909Z",
    "trendIndication": "lessSevere",
    "href": "http://localhost:8080/alert/b95eff87-b921-49e5-95de-d7a016511f65",
    "rawData": "",
    "previousSeverity": "critical",
    "event": "{{ .Name }}",
    "group": "Misc",
    "severity": "ok",
    "service": [],
    "id": "b95eff87-b921-49e5-95de-d7a016511f65",
    "environment": "Development",
    "type": "exceptionAlert",
    "status": "closed",
    "repeat": false,
    "tags": [],
    "createTime": "2016-03-10T14:30:39.904Z",
    "lastReceiveId": "fe8eb4fe-9d1d-4709-bd0c-f5cd96136434",
    "customer": null,
    "resource": "{{ .ID }}",
    "duplicateCount": 0,
    "correlate": [],
    "value": "{{ index .Fields "used" | printf "%0.0f" }}",
    "timeout": 86400,
    "attributes": {
      "ip": "127.0.0.1"
    },
    "history": []
  }
}

Any idea if this is a bug or am I doing something wrong?

thanks in advance :)

@skylenet
Copy link
Author

I noticed about this PR: #228

So I downloaded a recent nightly build ( Kapacitor 0.11.0~n1457683528 (git: master 1671023) and it seems to be working there 👍

@hrzbrg
Copy link

hrzbrg commented Mar 14, 2016

Hi,

even with the latest nightly I still have the problem, that I can not use a tag in environment section:

        .alerta()
          .value('{{ index .Fields "mean" | printf "%.2f" }} %')
          .resource('{{ index .Tags "service" }}')
          .environment('{{ index .Tags "env" }}')

The env tag is correctly printed in the message however and the service tag is correctly printed as the resource. Thats a strange behavior here :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants