Skip to content

Commit

Permalink
Merge pull request #41 from grafana/dev
Browse files Browse the repository at this point in the history
Merge dev to main
  • Loading branch information
iskhakov authored Jun 13, 2022
2 parents 2490a97 + b3add5c commit f6b7c0a
Show file tree
Hide file tree
Showing 77 changed files with 549 additions and 2,464 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ frontend/node_modules
frontend/build
package-lock.json
./engine/extensions
.env
.env
.env-hobby
9 changes: 7 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,13 @@ services:

trigger:
event:
- push
include:
- tag
- push
ref:
include:
- refs/heads/**
- refs/tags/v*.*.*

---
# Secret for pulling docker images.
Expand Down Expand Up @@ -231,6 +236,6 @@ kind: secret
name: drone_token
---
kind: signature
hmac: 81b9b7cda5a8f8525f40f39821be50881e0c4cb0c40a45b3e63bc0cc47274649
hmac: 5cdafa5ca416acb1763d1d9ac93bbd932982c874718f40af533914a6711c1a1f

...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.pyc
venv
.env
.env_hobby
.vscode
dump.rdb
.idea
Expand Down
11 changes: 4 additions & 7 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

1. Start stateful services (RabbitMQ, Redis, Grafana with mounted plugin folder)
```bash
docker-compose -f developer-docker-compose.yml up -d
docker-compose -f docker-compose-developer.yml up -d
```

2. Prepare a python environment:
Expand All @@ -53,9 +53,6 @@ export $(grep -v '^#' .env | xargs -0)
# Hint: there is a known issue with uwsgi. It's not used in the local dev environment. Feel free to comment it in `engine/requirements.txt`.
cd engine && pip install -r requirements.txt

# Create folder for database
mkdir sqlite_data

# Migrate the DB:
python manage.py migrate

Expand Down Expand Up @@ -107,7 +104,7 @@ python manage.py issue_invite_for_the_frontend --override
OnCall API URL:
http://host.docker.internal:8000
OnCall Invitation Token (Single use token to connect Grafana instance):
Invitation Token (Single use token to connect Grafana instance):
Response from the invite generator command (check above)
Grafana URL (URL OnCall will use to talk to Grafana instance):
Expand All @@ -119,7 +116,7 @@ host IP from inside the container by running:
```bash
/sbin/ip route|awk '/default/ { print $3 }'

# Alternatively add host.docker.internal as an extra_host for grafana in developer-docker-compose.yml
# Alternatively add host.docker.internal as an extra_host for grafana in docker-compose-developer.yml
extra_hosts:
- "host.docker.internal:host-gateway"

Expand Down Expand Up @@ -260,7 +257,7 @@ lt --port 8000 -s pretty-turkey-83 --print-requests
or set BASE_URL Env variable through web interface.
8. Edit grafana-plugin/src/plugin.json to add `Bypass-Tunnel-Reminder` header section for all existing routes
> this headers required for the local development only, otherwise localtunnel blocks requests from grafana plugin
> this headers required for the local development only, otherwise localtunnel blocks requests from grafana plugin, An alternative to this is you can modify your user-agent in your browser to bypass the tunnel warning, it only filters the common browsers.

```
{
Expand Down
85 changes: 35 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,61 @@
# Grafana OnCall Incident Response
Grafana OnCall, cloud version of Grafana OnCall: https://grafana.com/products/cloud/
<img width="400px" src="docs/img/logo.png">

Developer-friendly, incident response management with brilliant Slack integration.
- Connect monitoring systems
- Collect and analyze data
- On-call rotation
- Automatic escalation
- Never miss alerts with calls and SMS
Developer-friendly, incident response with brilliant Slack integration.

![Grafana OnCall Screenshot](screenshot.png)
<img width="60%" src="screenshot.png">

- Collect and analyze alerts from multiple monitoring systems
- On-call rotations based on schedules
- Automatic escalations
- Phone calls, SMS, Slack, Telegram notifications

## Getting Started
OnCall consists of two parts:
1. OnCall backend
2. "Grafana OnCall" plugin you need to install in your Grafana

### How to run OnCall backend
1. An all-in-one image of OnCall is available on docker hub to run it:
We prepared multiple environments: [production](PRODUCTION.md), [developer](DEVELOPER.md) and hobby:

1. Download docker-compose.yaml:
```bash
docker run -it --name oncall-backend -p 8000:8000 grafana/oncall-all-in-one
curl https://github.com/grafana/oncall/blob/dev/docker-compose.yml -o docker-compose.yaml
```

2. When the image starts up you will see a message like this:
2. Set variables:
```bash
👋 This script will issue an invite token to securely connect the frontend.
Maintainers will be happy to help in the slack channel #grafana-oncall: https://slack.grafana.com/
Your invite token: <TOKEN>, use it in the Grafana OnCall plugin.
echo "DOMAIN=http://localhost
SECRET_KEY=my_random_secret_must_be_more_than_32_characters_long
RABBITMQ_PASSWORD=rabbitmq_secret_pw
MYSQL_PASSWORD=mysql_secret_pw
COMPOSE_PROFILES=with_grafana # Remove this line if you want to use existing grafana
GRAFANA_USER=admin
GRAFANA_PASSWORD=admin" > .env_hobby
```

3. If you started your container detached with -d check the log:
3. Launch services:
```bash
docker logs oncall-backend
docker-compose --env-file .env_hobby -f docker-compose.yml up --build -d
```

### How to install "Grafana OnCall" Plugin and connect with a backend
1. Open Grafana in your browser and login as an Admin
2. Navigate to Configuration &rarr; Plugins
3. Type Grafana OnCall into the "Search Grafana plugins" field
4. Select the Grafana OnCall plugin and press the "Install" button
5. On the Grafana OnCall Plugin page Enable the plugin and go to the Configuration tab you should see a status field with the message
4. Issue one-time invite token:
```bash
docker-compose --env-file .env_hobby -f docker-compose.yml run engine python manage.py issue_invite_for_the_frontend --override
```
OnCall has not been setup, configure & initialize below.

5. Go to [OnCall Plugin Configuration](http://localhost:3000/plugins/grafana-oncall-app) (or find OnCall plugin in configuration->plugins) and connect OnCall _plugin_ with OnCall _backend_:
```
6. Fill in configuration fields using the token you got from the backend earlier, then press "Install Configuration"
Invite token: ^^^ from the previous step.
OnCall backend URL: http://engine:8080
Grafana Url: http://grafana:3000
```
OnCall API URL: (The URL & port used to access OnCall)
http://host.docker.internal:8000
OnCall Invitation Token (Single use token to connect Grafana instance):
Invitation token from docker startup

Grafana URL (URL OnCall will use to talk to this Grafana instance):
http://localhost:3000 (or http://host.docker.internal:3000 if your grafana is running in Docker locally)
```
6. Enjoy!

## Getting Help
- `#grafana-oncall` channel at https://slack.grafana.com/
- Grafana Labs community forum for OnCall: https://community.grafana.com
- File an [issue](https://github.com/grafana/oncall/issues) for bugs, issues and feature suggestions.

## Production Setup
## Join community

Looking for the production instructions? We're going to release them soon. Please join our Slack channel to be the first to know about them.
<a href="https://github.com/grafana/oncall/discussions/categories/community-calls"><img width="200px" src="docs/img/community_call.png"></a>
<a href="https://github.com/grafana/oncall/discussions"><img width="200px" src="docs/img/GH_discussions.png"></a>
<a href="https://slack.grafana.com/"><img width="200px" src="docs/img/slack.png"></a>

## Further Reading
- *Documentation* - [Grafana OnCall](https://grafana.com/docs/grafana-cloud/oncall/)
- *Blog Post* - [Announcing Grafana OnCall, the easiest way to do on-call management](https://grafana.com/blog/2021/11/09/announcing-grafana-oncall/)
- *Presentation* - [Deep dive into the Grafana, Prometheus, and Alertmanager stack for alerting and on-call management](https://grafana.com/go/observabilitycon/2021/alerting/?pg=blog)

## FAQ

- How do I generate a new invitation token to connect plugin with a backend?
```bash
docker exec oncall-backend python manage.py issue_invite_for_the_frontend --override
```
8 changes: 4 additions & 4 deletions developer-docker-compose.yml → docker-compose-developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: local_dev_pwd
MYSQL_ROOT_PASSWORD: empty
MYSQL_DATABASE: oncall_local_dev
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
Expand Down Expand Up @@ -42,21 +42,21 @@ services:
mysql-to-create-grafana-db:
image: mariadb:10.2
platform: linux/x86_64
command: bash -c "mysql -h mysql -uroot -plocal_dev_pwd -e 'CREATE DATABASE IF NOT EXISTS grafana CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'"
command: bash -c "mysql -h mysql -uroot -pempty -e 'CREATE DATABASE IF NOT EXISTS grafana CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'"
depends_on:
mysql:
condition: service_healthy

grafana:
image: "grafana/grafana:8.5.5"
image: "grafana/grafana:9.0.0-beta3"
restart: always
mem_limit: 500m
cpus: 0.5
environment:
GF_DATABASE_TYPE: mysql
GF_DATABASE_HOST: mysql
GF_DATABASE_USER: root
GF_DATABASE_PASSWORD: local_dev_pwd
GF_DATABASE_PASSWORD: empty
GF_SECURITY_ADMIN_USER: oncall
GF_SECURITY_ADMIN_PASSWORD: oncall
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: grafana-oncall-app
Expand Down
Loading

0 comments on commit f6b7c0a

Please sign in to comment.