suzuki-shunsuke / go-graylog

Graylog API client for Go and terraform provider for Graylog
https://github.com/terraform-provider-graylog/terraform-provider-graylog
MIT License
45 stars 11 forks source link

support for AlertManager plugin #296

Closed Luubosi closed 4 years ago

Luubosi commented 4 years ago

Please, could you add support for AlertManager plugin? resource "graylog_alarm_callback" "alertmanager"

we are using this version: https://github.com/GDATASoftwareAG/Graylog-Plugin-AlertManager-Callback/releases/download/1.2.1/graylog-plugin-alertmanagercallback-1.2.1.jar

Would it be possible to add to version graylog provider: go-graylog-10.0.1 we are using graylog 3.0.2

`get /alerts/callbacks/types

{
  "types": {
    "de.gdata.mobilelab.alertmanagercallback.AlertManagerAlarmCallback": {
      "name": "AlertManager Callback",
      "requested_configuration": {
        "alertmanager_api_url": {
          "human_name": "AlertManager API URL",
          "additional_info": {},
          "description": "This callback sends a POST-Request to an AlertManager API. It converts the information into a format which is readable by the AlertManager.",
          "default_value": "http://localhost:9093/api/v1/alerts",
          "attributes": [],
          "type": "text",
          "is_optional": false
        },
        "alertmanager_alert_name": {
          "human_name": "AlertManager Alert Name",
          "additional_info": {},
          "description": "The name for the specific AlertManager alert (will be transmitted as 'alertname'-label).",
          "default_value": "TestAlert",
          "attributes": [],
          "type": "text",
          "is_optional": false
        },
        "alertmanager_custom_labels": {
          "human_name": "Custom AlertManager labels",
          "additional_info": {},
          "description": "The custom AlertManager label key-value-pairs separated by ';' to set for each alert. Please use the following notation: 'label1=value1;label2=value2;streamtitle=${stream.title}'. You can use the JMTE-Template annotation within values of your custom labels to get live information from triggered alert.",
          "default_value": "",
          "attributes": [],
          "type": "text",
          "is_optional": true
        },
        "alertmanager_custom_annotations": {
          "human_name": "Custom AlertManager annotations",
          "additional_info": {},
          "description": "The custom AlertManager annotation key-value-pairs separated by ';' to set for each alert. Please use the following notation: 'annotation1=value1;annotation2=value2;streamtitle=${stream.title}'. You can use the JMTE-Template annotation within values of your custom annotations to get live information from triggered alert.",
          "default_value": "",
          "attributes": [],
          "type": "text",
          "is_optional": true
        }
      }
    }
  }
}

Our configuration: get /alerts/callbacks

{
  "total": 2,
  "alarmcallbacks": [
    {
      "id": "5f102020590801000f68e2fa",
      "type": "de.gdata.mobilelab.alertmanagercallback.AlertManagerAlarmCallback",
      "configuration": {
        "alertmanager_custom_annotations": "streamtitle=${stream.title};severity=critical",
        "alertmanager_api_url": "http://localhost:9093/api/v1/alerts",
        "alertmanager_alert_name": "GraylogTestAlert",
        "alertmanager_custom_labels": " streamtitle=${stream.title};sourcelabel=graylog"
      },
      "stream_id": "5e6247f552faff000f091da4",
      "title": "alertmanagercallback",
      "created_at": "2020-07-16T09:38:40.574+0000",
      "creator_user_id": "admin"
    }
  ]
}
suzuki-shunsuke commented 4 years ago

Please use code syntax hight light for readability. https://github.github.com/gfm/#fenced-code-blocks And please consider to migrate to terraform-provider-graylog/terraform-provider-graylog.

If you use go-graylog, please read the document. https://github.com/suzuki-shunsuke/go-graylog/blob/master/docs/resources/alarm_callback.md#type-other-third-partys-alarm-callback

I don't try it yet, but maybe it works well.

Luubosi commented 4 years ago

hi, thanks very much for your help, this works :)

resource "graylog_alarm_callback" "tfAlertmanagercallback" {
  type      = "de.gdata.mobilelab.alertmanagercallback.AlertManagerAlarmCallback"
  stream_id = "5e6247f552faff000f091da4"
  #stream_id = graylog_stream.test.id
  title     = "tfAlertmanagercallback"
  general_string_configuration = {
    alertmanager_custom_annotations = "severity=critical,streamtitle=streamtitle"
    alertmanager_api_url = "http://fqdn:9093/api/v1/alerts"
    alertmanager_alert_name = "tfAlertmanagercallback"
    alertmanager_custom_labels = "sourcelabel=graylog,streamtitle=streamtitle"
  }
}