Skip to content

Alerting action trigger script #2593

Answered by rahulguptajss
wooyoungAhn asked this question in Q&A
Discussion options

You must be logged in to vote

@wooyoungAhn You can use prometheus alert manager through a webhook. Below are the sample steps.

Setting Up a Webhook Receiver with Golang and Prometheus Alertmanager

Prerequisites

  • Prometheus and Alertmanager installed and configured.
  • Golang installed

Step 1: Create the Go Webhook Receiver

Create a new Go file (e.g., main.go) and add the following code. You can invoke a script in go code as needed.

package main

import (
	"fmt"
	"io"
	"log"
	"net/http"
)

func alertHandler(w http.ResponseWriter, r *http.Request) {
	body, err := io.ReadAll(r.Body)
	if err != nil {
		http.Error(w, "Error reading request body",
			http.StatusInternalServerError)
		return
	}

	// Print the received data
	fmt.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by wooyoungAhn
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants