{"id":15778840,"url":"https://github.com/v5tech/spring-boot-prometheus-grafana-example","last_synced_at":"2025-09-11T04:38:34.758Z","repository":{"id":149461789,"uuid":"117331615","full_name":"v5tech/spring-boot-prometheus-grafana-example","owner":"v5tech","description":"Demo project for Spring Boot Prometheus Grafana Sample","archived":false,"fork":false,"pushed_at":"2018-01-13T09:42:37.000Z","size":193,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T02:46:46.483Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/v5tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-01-13T09:37:36.000Z","updated_at":"2018-07-23T07:53:53.000Z","dependencies_parsed_at":"2023-04-19T03:16:44.029Z","dependency_job_id":null,"html_url":"https://github.com/v5tech/spring-boot-prometheus-grafana-example","commit_stats":null,"previous_names":["v5tech/spring-boot-prometheus-grafana-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/v5tech/spring-boot-prometheus-grafana-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v5tech%2Fspring-boot-prometheus-grafana-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v5tech%2Fspring-boot-prometheus-grafana-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v5tech%2Fspring-boot-prometheus-grafana-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v5tech%2Fspring-boot-prometheus-grafana-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/v5tech","download_url":"https://codeload.github.com/v5tech/spring-boot-prometheus-grafana-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v5tech%2Fspring-boot-prometheus-grafana-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274578426,"owners_count":25310955,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T18:01:28.893Z","updated_at":"2025-09-11T04:38:34.741Z","avatar_url":"https://github.com/v5tech.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spring-boot-prometheus-grafana-example\n\n服务器监控和告警系统`Bosun`,`cAdvisor`,`Prometheus`\n\n## 安装 Prometheus\n\n获取 Prometheus 的 Docker 镜像：\n\n```bash\n$ docker pull prom/prometheus\n```\n\n编写 prometheus.yml 配置文件 \n\n```yml\nglobal:\n  scrape_interval: 10s\n  scrape_timeout: 10s\n  evaluation_interval: 10m\nscrape_configs:\n  - job_name: spring-boot\n    scrape_interval: 5s\n    scrape_timeout: 5s\n    metrics_path: /manager/prometheus\n    scheme: http\n    basic_auth:\n      username: admin\n      password: admin\n    static_configs:\n      - targets:\n        - 192.168.31.201:9898  #此处填写 Spring Boot 应用的 IP + 端口号\n```\n\n启动 Prometheus\n\n```bash\n$ docker run -d \\\n--name prometheus \\\n-p 9090:9090 \\\n-m 500M \\\n-v \"$(pwd)/prometheus.yml\":/prometheus.yml \\\n-v \"$(pwd)/data\":/data \\\nprom/prometheus \\\n--config.file=/prometheus.yml \\\n--log.level=info\n```\n\n访问 http://192.168.31.216:9090/targets , 检查 Spring Boot 采集状态是否正常。\n\n![](Screenshots/prometheus_targets.png)\n![](Screenshots/prometheus_config.png)\n![](Screenshots/prometheus_graph.png)\n\n## Grafana 可视化监控数据\n\n获取 Grafana 的 Docker 镜像\n\n```bash\n$ docker pull grafana/grafana\n```\n\n然后，启动 Grafana：\n\n```bash\n$ docker run --name grafana -d -p 3000:3000 grafana/grafana\n```\n\n接着，访问 http://localhost:3000/ 配置 Prometheus 数据源：\n\nGrafana 登录账号 admin 密码 admin\n\n然后在 Grafana 中配置各监控指标\n\n![](Screenshots/spring-boot-grafana.png)\n\n## 参考文章\n\nhttps://www.jianshu.com/p/7ecb57a3f326\n\nhttp://qinghua.github.io/prometheus\n\nhttps://prometheus.io/docs/prometheus/latest/installation/#using-docker\n\nhttp://docs.grafana.org/installation/docker/\n\nhttp://www.ywnds.com/?p=9668\n\nhttp://www.ywnds.com/?cat=122\n\nhttp://bosun.org/quickstart\n\nhttp://blog.yiyun.pro","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv5tech%2Fspring-boot-prometheus-grafana-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv5tech%2Fspring-boot-prometheus-grafana-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv5tech%2Fspring-boot-prometheus-grafana-example/lists"}