diff --git a/README.md b/README.md index 662e53b..bb09f44 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 +``` \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..0c3c828 --- /dev/null +++ b/docker-compose.yaml @@ -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 diff --git a/prometheus/prometheus.yaml b/prometheus/prometheus.yaml new file mode 100644 index 0000000..343e082 --- /dev/null +++ b/prometheus/prometheus.yaml @@ -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'