I dont think the webhook receiver config supports templates. If your api
receiver does not accept the json payload sent by alertmanager then you may
need to write a custom translator something like a small flask app that can
receive the data from alertmanager, process it and push it to your api.

On Tue, Mar 24, 2020, 11:13 PM Rahul Hada <[email protected]> wrote:

> I am able to get json data, but was looking for more appropriate template
> so that could send only required parameters to the api. Any suggestions for
> that would be appreciated.
>
> On Wed, 25 Mar, 2020, 9:30 AM Murali Krishna Kanagala, <
> [email protected]> wrote:
>
>> To send an alert to a web hook there is no need for a template. The
>> receiver api receivs the alerts in as json payload.
>>
>> https://prometheus.io/docs/alerting/configuration/#webhook_config
>>
>>
>> On Tue, Mar 24, 2020, 12:46 AM Rahul Hada <[email protected]> wrote:
>>
>>> Hi All,
>>> We are using templates to refine the parameters going to the slack
>>> channel from alertmanager, we do have one api to which we are sending alert
>>> notifications but while using same templates for api, reloading the
>>> alertmanager.yml gives error " field title not found in type config.plain".
>>> I have rechecked if there is any indentation error in yaml file. Please
>>> suggest whether it is possible for api or not. If yes , please guide me
>>> towards it.
>>>
>>> Template file :-
>>> {{ define "webhook.default.title" }}{{ template "__subject" . }}{{ end }}
>>> {{ define "webhook.default.username" }}{{ template "__alertmanager" .
>>> }}{{ end }}
>>> {{ define "webhook.default.fallback" }}{{ template
>>> "webhook.default.title" . }} | {{ template "webhook.default.titlelink" .
>>> }}{{ end }}
>>> {{ define "webhook.default.pretext" }}{{ end }}
>>> {{ define "webhook.default.titlelink" }}{{ template "__alertmanagerURL"
>>> . }}{{ end }}
>>> {{ define "webhook.default.iconemoji" }}{{ end }}
>>> {{ define "webhook.default.iconurl" }}{{ end }}
>>> {{ define "webhook.default.text" }}{{ end }}
>>> {{ define "webhook.default.footer" }}{{ end }}
>>>
>>>
>>> Alertmanager.yml file :-
>>> - name: "en_api"
>>>   webhook_configs:
>>>   - url: http://dticket.xxxxxxx.com/prometheus_api.php
>>>     title: '{{ template "webhook.default.title" . }}'
>>>     text: |-
>>>       {{ range .Alerts }}
>>>          *ALERT:* {{ .Annotations.summary }} - `{{ .Labels.severity }}`
>>>         *DESCRIPTION:* {{ .Annotations.description }}
>>>         {{ .Annotations.identifier }}
>>>       {{ end }}
>>>
>>>
>>> Thanks in Advance
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Prometheus Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/prometheus-users/c01b22eb-828d-4df2-bcea-f6e448ab2ca5%40googlegroups.com
>>> <https://groups.google.com/d/msgid/prometheus-users/c01b22eb-828d-4df2-bcea-f6e448ab2ca5%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Prometheus Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/prometheus-users/CAKimyZvybwitKXoPBy5MbxS6NDab-bybKecsr2DiqK8Z55s20w%40mail.gmail.com
>> <https://groups.google.com/d/msgid/prometheus-users/CAKimyZvybwitKXoPBy5MbxS6NDab-bybKecsr2DiqK8Z55s20w%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/CAKimyZu2zpHV2zLYR7Rnh9FpXe0zoQon3J59tAA47_kdX_tfWg%40mail.gmail.com.

Reply via email to