Last active
April 28, 2025 10:29
-
-
Save zettalyst/0ebe1b2836e3646327ebadb036196f89 to your computer and use it in GitHub Desktop.
monitoring_lecture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services: | |
| prometheus: | |
| image: prom/prometheus:v3.3.0 | |
| volumes: | |
| - ./prometheus.yml:/etc/prometheus/prometheus.yml | |
| command: | |
| - '--config.file=/etc/prometheus/prometheus.yml' | |
| ports: | |
| - '9090:9090' | |
| node_exporter: | |
| image: prom/node-exporter:v1.9.1 | |
| volumes: | |
| - /proc:/host/proc:ro | |
| - /sys:/host/sys:ro | |
| - /:/rootfs:ro | |
| command: | |
| - '--path.procfs=/host/proc' | |
| - '--path.rootfs=/rootfs' | |
| - '--path.sysfs=/host/sys' | |
| - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)' | |
| ports: | |
| - '9100:9100' | |
| grafana: | |
| image: grafana/grafana-oss:11.6.1 | |
| environment: | |
| - GF_SECURITY_ADMIN_PASSWORD=admin # Set the admin password | |
| - GF_USERS_ALLOW_SIGN_UP=false | |
| ports: | |
| - '3000:3000' | |
| depends_on: | |
| - prometheus | |
| mysql: | |
| image: mysql:8.0 | |
| environment: | |
| - MYSQL_ROOT_PASSWORD=rootpassword | |
| - MYSQL_DATABASE=mydb | |
| - MYSQL_USER=user | |
| - MYSQL_PASSWORD=password | |
| volumes: | |
| - mysql_data:/var/lib/mysql | |
| ports: | |
| - '3306:3306' | |
| volumes: | |
| mysql_data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| global: | |
| scrape_interval: 15s | |
| scrape_configs: | |
| - job_name: 'prometheus' # prometheus | |
| static_configs: | |
| - targets: ['localhost:9090'] | |
| - job_name: 'node' # node_exporter | |
| static_configs: | |
| - targets: ['node_exporter:9100'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH daily_counts AS ( | |
| SELECT | |
| DATE(created_at) AS date, | |
| COUNT(id) AS daily_user_count | |
| FROM | |
| users | |
| GROUP BY | |
| date | |
| ) | |
| SELECT | |
| UNIX_TIMESTAMP(date) AS time_sec, | |
| SUM(daily_user_count) OVER (ORDER BY date) AS cumulative_user_count | |
| FROM | |
| daily_counts | |
| ORDER BY | |
| time_sec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment