Compare commits

..

No commits in common. "main" and "1.0.0" have entirely different histories.
main ... 1.0.0

6 changed files with 15 additions and 18 deletions

View File

@ -1,5 +1,4 @@
.dockerignore .dockerignore
.drone.yml
.git* .git*
Dockerfile Dockerfile
data data

View File

@ -5,22 +5,20 @@ type: docker
name: default name: default
steps: steps:
- name: build only - name: build
image: plugins/docker image: plugins/docker
settings: settings:
dry_run: yes dry_run: yes
purge: no
repo: git.luj0ga.de/luca/matrix-prometheus repo: git.luj0ga.de/luca/matrix-prometheus
when:
event:
exclude:
- tag
- name: build and publish - name: publish
image: plugins/docker image: plugins/docker
settings: settings:
auto_tag: yes auto_tag: yes
password: password:
from_secret: access_token from_secret: access_token
purge: no
registry: git.luj0ga.de registry: git.luj0ga.de
repo: git.luj0ga.de/luca/matrix-prometheus repo: git.luj0ga.de/luca/matrix-prometheus
username: _ username: _

View File

@ -24,6 +24,4 @@ USER matrix-prometheus
VOLUME /data VOLUME /data
WORKDIR /data WORKDIR /data
EXPOSE 8000
CMD ["/usr/local/bin/matrix-prometheus"] CMD ["/usr/local/bin/matrix-prometheus"]

View File

@ -7,6 +7,7 @@ services:
restart: unless-stopped restart: unless-stopped
environment: environment:
ALLOWED_ROOMS: ALLOWED_ROOMS:
DATABASE: /data/db.sqlite3
DEVICE_NAME: $HOSTNAME DEVICE_NAME: $HOSTNAME
HOMESERVER: 'https://matrix.org' HOMESERVER: 'https://matrix.org'
PASSWORD: PASSWORD:

View File

@ -20,6 +20,7 @@ const (
) )
func FromEnv() Config { func FromEnv() Config {
db := requireEnv("DATABASE")
deviceName := requireEnv("DEVICE_NAME") deviceName := requireEnv("DEVICE_NAME")
homeserver := requireEnv("HOMESERVER") homeserver := requireEnv("HOMESERVER")
userId := requireEnv("USER_ID") userId := requireEnv("USER_ID")
@ -28,11 +29,6 @@ func FromEnv() Config {
allowedRooms := os.Getenv("ALLOWED_ROOMS") allowedRooms := os.Getenv("ALLOWED_ROOMS")
db := os.Getenv("DATABASE")
if db == "" {
db = "/data/db.sqlite3"
}
greeting := os.Getenv("GREETING") greeting := os.Getenv("GREETING")
if greeting == "" { if greeting == "" {
greeting = defaultGreeting greeting = defaultGreeting

View File

@ -11,13 +11,13 @@ import (
const ( const (
messageTemplate = "\U0001f6a8" + messageTemplate = "\U0001f6a8" +
` **New alerts:** @room{{ range .Alerts }} ` **Alerts for group "_{{ .GroupKey }}_":**{{ range .Alerts }}
` + "\u2022" + ` {{ if eq .Status "` + StatusResolved + `" }}` + "\u2705" + ` + "\u2022" + ` {{ with .Labels.severity }}{{ if eq . "critical" }}` + "\U0001f525" +
`{{ else }}{{ with .Labels.severity }}{{ if eq . "critical" }}` + "\U0001f525" +
`{{ else if eq . "warning" }}` + "\U0001f4e2" + `{{ else if eq . "warning" }}` + "\U0001f4e2" +
`{{ else }}` + "\U0001f514" + `{{ else }}` + "\U0001f514" +
`{{ end }}{{ else }}` + "\U0001f514" + `{{ end }}{{ else }}` + "\U0001f514" +
`{{ end }}{{ end }} {{ .Annotations.description }}{{ end }}` `{{ end }} {{ .Annotations.description }}{{ end }}
@room`
) )
func (s Server) handleWebhook(w http.ResponseWriter, r *http.Request) { func (s Server) handleWebhook(w http.ResponseWriter, r *http.Request) {
@ -40,6 +40,11 @@ func (s Server) handleWebhook(w http.ResponseWriter, r *http.Request) {
return return
} }
if payload.Status != StatusFiring {
writeStatus(w, http.StatusOK)
return
}
var message bytes.Buffer var message bytes.Buffer
err = s.tmpl.Execute(&message, payload) err = s.tmpl.Execute(&message, payload)
if err != nil { if err != nil {