Categorygithub.com/13rentgen/grafana-annotations-bot

# Packages

No description provided by the author

# README

Telegram Bot for Grafana's Annotations

Build Status Docker Repository on Quay

This is the Grafana annotations Telegram bot that notifies you when new annotations will be added to Grafana.

Commands

/start tagName,anotherOneTag

You're subscribe for tags: tagName anotherOneTag

/stop

You're successfully unsubscribe for tags: tagName anotherOneTag

/status

Grafana Version: 5.4.2 Database: ok

Telegram Bot Version: go1.11.4 Uptime: Thu, 21 Mar 2019 11:45:24 MSK

Installation

Docker

docker pull quay.io/13rentgen/grafana-annotations-bot:1.1.0

Bolt Storage

docker run -d \
	-e 'GRAFANA_URL=http://grafana:3000' \
	-e 'GRAFANA_TOKEN=XXX' \
	-e 'STORE=bolt' \
    -e 'BOLT_PATH=/data/bot.db' \
	-e 'TELEGRAM_ADMIN=1234567' \
	-e 'TELEGRAM_TOKEN=XXX' \
	-e 'TEMPLATE_PATH=/templates/default.tmpl' \
	-v '/data/grafana-annotations-bot:/data' \
	-v '${PWD}/default.tmpl:/templates/default.tmpl' \
	--name grafana-annotations-bot \
	quay.io/13rentgen/grafana-annotations-bot:1.1.0

ETCD Storage

docker run -d \
	-e 'GRAFANA_URL=http://grafana:3000' \
	-e 'GRAFANA_TOKEN=XXX' \
	-e 'STORE=etcd' \
	-e 'ETCD_URL=localhost:2379' \
	-e 'ETCD_TLS_INSECURE=true' \
	-e 'TELEGRAM_ADMIN=1234567' \
	-e 'TELEGRAM_TOKEN=XXX' \
	-e 'TEMPLATE_PATH=/templates/default.tmpl' \
	-v '/data/grafana-annotations-bot:/data' \
	-v '${PWD}/default.tmpl:/templates/default.tmpl' \
	--name grafana-annotations-bot \
	quay.io/13rentgen/grafana-annotations-bot:1.1.0

Build from source

go get github.com/13rentgen/grafana-annotations-bot

Configuration

FlagENVRequiredDefaultDescription
--grafana.urlGRAFANA_URLTrueThe URL that's used to connect to the Grafana, example: http://localhost:3000
--grafana.tokenGRAFANA_TOKENTrueThe Bearer token used to connect with Grafana API
--grafana.scrapeIntervalGRAFANA_SCRAPE_INTERVALFalse10sScrape annotations interval
--grafana.tls.insecureGRAFANA_TLS_INSECUREFalsefalseInsecure connection to Grafana API
--grafana.tls.insecureSkipVerifyGRAFANA_TLS_INSECURE_SKIP_VERIFYFalsefalseGrafana TLS config - insecure skip verify
--grafana.tls.certGRAFANA_TLS_CERTFalseGrafana TLS config - client cert file path
--grafana.tls.keyGRAFANA_TLS_KEYFalseGrafana TLS config - client key file path
--store.typeSTORE_TYPEFalseboltThe store to use. Possible values: bolt, etcd
--store.keyPrefixSTORE_KEY_PREFIXFalseannotationsbot/chatsPrefix for store keys
--bolt.pathBOLT_PATHFalse/tmp/bot.dbBolt database file path
--etcd.urlETCD_URLFalselocalhost:2379
--etcd.tls.insecureETCD_TLS_INSECUREFalsefalseInsecure connection to ETCD
--etcd.tls.insecureSkipVerifyETCD_TLS_INSECURE_SKIP_VERIFYFalsefalseETCD TLS config - insecure skip verify
--etcd.tls.certETCD_TLS_CERTFalseETCD TLS config - client cert file path
--etcd.tls.keyETCD_TLS_KEYFalseETCD TLS config - client key file path
--etcd.tls.caETCD_TLS_CAFalseETCD TLS config - CA file path
--log.jsonLOG_JSONFalsefalseTell the application to log json, default: false
--log.levelLOG_LEVELFalseinfoThe log level to use for filtering logs, possible values: debug, info, warn, error
--telegram.tokenTELEGRAM_TOKENTrueThe token used to connect with Telegram. Token you get from @botfather
--template.pathTEMPLATE_PATHTrueThe path to the template
--telegram.adminTELEGRAM_ADMINTrueTelegram admin IDs

Authentication

Users may be allowed to command the bot specifies by multiply --telegram.admin command line option.

Example:

grafana-annotations-bot --telegram.admin=123 --telegram.admin=456

Or by specifying a newline-separated list of telegram user IDs in the TELEGRAM_ADMIN environment variable.

Example:

TELEGRAM_ADMIN="123\n456" grafana-annotations-bot

Message template

Message template specifies by --template.path command line option or by TEMPLATE_PATH environment variable. Default template

Template variables
Go template variableTypeDescription
{{.Title}}stringAnnotation title
{{.Message}}stringAnnotation message
{{.Tags}}[]stringAnnotation tags
{{.JoinedTags}}stringAnnotation tags joined to string by new line separator
{{.FormattedDate}}stringAnnotation date in RFC1123 format
{{.Text}}stringRaw annotation body string

License

MIT