Skip to content

Commit

Permalink
Feature/docker (#3)
Browse files Browse the repository at this point in the history
* ➕ username

* ✈️ compose and prometheus configuration

* ✔️ compose configuration

* ✔️ remove compose option
  • Loading branch information
dbgjerez authored Apr 25, 2022
1 parent 51325da commit 5270ae8
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ REPO_NAME_CONTAINS=string-to-match-repositories-with # Default: ""
CRONTAB_SCHEDULE=crontab-schedule-to-get-data-from-github # Default: "0 * * * *"
```

**_NOTE:_** You also can use your username if you don't belong to any organization. In this case, use "USERNAME" instead of "ORG_NAME".

Run the image:
```
$ docker run --env-file .env -it -p 8001:8001 ghcr.io/grafana/github-traffic
Expand All @@ -36,3 +38,35 @@ Profit!

Now you can collect those metrics as you would do with any other service. To visualize them, we provide an example/template Grafana dashboard: https://grafana.com/grafana/dashboards/15000

## Docker compose
In addition, a docker-compose.yaml file is provided. This file also run Prometheus and Grafana.

**_NOTE:_** You've to create the .env file with you configuration.

Run compose:
```zsh
❯ docker-compose up -d
Creating network "github-traffic_default" with the default driver
Creating github-traffic_traffic_1 ... done
Creating github-traffic_prometheus_1 ... done
Creating github-traffic_grafana_1 ... done
```

Now, you can access to:
* Grafana: http://localhost:3000
* Prometheus: http://localhost:9090
* Github traffic: http://localhost:8001

Once you navigate to Grafana (http://localhost:3000), the user and password are admin/admin you have to configure a datasource to Prometheus (http://prometheus:9090) and import the dashboard with id 15000.

Remove containers:
```zsh
❯ docker-compose down
Stopping github-traffic_grafana_1 ... done
Stopping github-traffic_prometheus_1 ... done
Stopping github-traffic_traffic_1 ... done
Removing github-traffic_grafana_1 ... done
Removing github-traffic_prometheus_1 ... done
Removing github-traffic_traffic_1 ... done
Removing network github-traffic_default
```
29 changes: 29 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
grafana:
image: 'grafana/grafana-oss'
ports:
- "3000:3000"
links:
- prometheus
dns:
- 8.8.8.8
prometheus:
image: 'prom/prometheus'
volumes:
- ./prometheus/:/etc/prometheus/
command:
- '--config.file=/etc/prometheus/prometheus.yaml'
ports:
- "9090:9090"
links:
- traffic
traffic:
image: 'ghcr.io/grafana/github-traffic'
ports:
- "8001:8001"
env_file:
- .env
restart:
on-failure
dns:
- 8.8.8.8
13 changes: 13 additions & 0 deletions prometheus/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
global:
scrape_interval: 30s
scrape_timeout: 10s

rule_files:
- alert.yml

scrape_configs:
- job_name: services
metrics_path: /metrics
static_configs:
- targets:
- 'traffic:8001'

0 comments on commit 5270ae8

Please sign in to comment.