Hi community,
I am looking for assistance with setting up alerts in Grafana using loki as the datasource. My goal is to send alerts to MS Teams with the specified timestamp and message from my log line attached.
Alert Requirements:
Timestamp: Extract the timestamp from the log line.
Message: Extract the message from the log line (e.g., “NoLocation Collision detected for number +1234523330666…”).
I am using this template for my contact point
//
{{define “lokiToMsTeams” }}
{
“title”: “Error in {{.Fields.app }}({{.Fields.container }})”,
“summary”: “Error encountered running importer process”,
“sections”: [
{
“activityTitle”: “Error Details”,
“activitySubtitle”: “Error message”,
“facts”: [
{
“name”: “App”,
“value”: “{{.Fields.app }}”
},
{
“name”: “Container”,
“value”: “{{.Fields.container }}”
},
{
“name”: “Filename”,
“value”: “{{.Fields.filename }}”
},
{
“name”: “Job”,
“value”: “{{.Fields.job }}”
},
{
“name”: “Namespace”,
“value”: “{{.Fields.namespace }}”
},
{
“name”: “Node Name”,
“value”: “{{.Fields.node_name }}”
},
{
“name”: “Pod”,
“value”: “{{.Fields.pod }}”
},
{
“name”: “Stream”,
“value”: “{{.Fields.stream }}”
}
],
“text”: “{{.Line }}”
}
]
}
{{end }}
//
My alerts on Teams appear like below
Could someone guide me on how to configure this alerts to Teams with the specified timestamp and message from log line? Any examples or documentation references would be great appreciated,
Thank you in advance for your help