Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit the link in a slack notification from Grafana

Tags:

slack

grafana

We are using Grafana 4 and have implemented alert notifications to a slack channel through an Incoming Webhook. The notifications are sent as and wen expected, except that the link in the notification points to the wrong place. For instance, if you take the following test notification:

enter image description here

Then I would expect the link in [Alerting] Test notification to point to the Grafana server. However, the host in that link is localhost. I thought it might be just a problem with test notifications, but this also happens with real notifications: the path will be correct, but the host and port will be wrong (localhost:62033, for full details).

I have tried to find the place where this host/port is configured, with no luck. Any tips so as to how to fix this?

Thanks in advance.

like image 448
quiram Avatar asked Dec 22 '16 12:12

quiram


People also ask

How can I update the Grafana dashboard URL in the slack notification?

You can do this either in grafana. ini (probably in your config map) or using environment variables, more about that here. The environment variable for ROOT_URL is GF_SERVER_ROOT_URL and should be set to whatever url you use to access Grafana. Sounds like it would be https://11.128.52.211:8443 in your case.


2 Answers

In addition to editing the grafana.ini, if you are running Grafana within a Docker container you can also pass this into the container using environment variables (example uses the default grafana/grafana container).

docker run \ -d \ -p 3000:3000 \ --name=grafana \ -e "GF_SERVER_ROOT_URL=http://grafana.server.name:3000" \ grafana/grafana

like image 40
dragon788 Avatar answered Oct 27 '22 19:10

dragon788


There are a number of options you can add to your ini file to tell Grafana how to build self-referential urls:

#################################### Server ############################## [server] # Protocol (http or https) protocol = http  # The http port  to use http_port = 3000  # The public facing domain name used to access grafana from a browser domain = localhost  # The full public facing url root_url = %(protocol)s://%(domain)s:%(http_port)s/ 

You should start by setting the protocol, http_port and domain to the proper values. If you're accessing Grafana on port 80 or 443 and don't want to have the port explicitly in the url you can remove :%(http_port) from the root_url setting.

like image 108
AussieDan Avatar answered Oct 27 '22 17:10

AussieDan