macOS Grafana Prometheus

    科技2024-07-15  65

    macOS Grafana

    安装Grafana运行Grafana停止Grafana升级Grafana登陆Grafana安装prometheus安装node_exporter

    安装Grafana

    ╰─➤ brew update ╰─➤ brew install grafana

    运行Grafana

    ╰─➤ brew services start grafana

    停止Grafana

    brew services stop grafana

    升级Grafana

    brew update brew reinstall grafana ╰─➤ grafana-server -v Version 7.0.0 (commit: unknown-dev, branch: master) ╰─➤ grafana-server -v Version 7.2.0 (commit: unknown-dev, branch: master)

    登陆Grafana

    默认用户名密码admin http://localhost:3000/login

    安装prometheus

    brew install prometheus

    运行prometheus

    brew services start prometheus ╰─➤ prometheus --version prometheus, version 2.21.0 (branch: non-git, revision: non-git) ╰─➤ cat /usr/local/etc/prometheus.yml global: scrape_interval: 15s scrape_configs: - job_name: "prometheus" static_configs: - targets: ["localhost:9090"] prometheus --config.file=/usr/local/etc/prometheus.yml ╰─➤ curl http://localhost:9090/metrics # HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 5.0972e-05 go_gc_duration_seconds{quantile="0.25"} 7.9818e-05 go_gc_duration_seconds{quantile="0.5"} 0.000109628 go_gc_duration_seconds{quantile="0.75"} 0.000211169 go_gc_duration_seconds{quantile="1"} 0.000414874 go_gc_duration_seconds_sum 0.004110919 go_gc_duration_seconds_count 28 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 38 # HELP go_info Information about the Go environment. # TYPE go_info gauge go_info{version="go1.15.1"} 1 http://localhost:9090/graph

    http://localhost:9090/metrics

    查看端口 lsof -i :9090

    安装node_exporter

    brew install node_exporter brew services start node_exporter ╰─➤ node_exporter level=info ts=2020-10-08T10:46:06.898Z caller=node_exporter.go:177 msg="Starting node_exporter" version="(version=1.0.1, branch=, revision=)" level=info ts=2020-10-08T10:46:06.898Z caller=node_exporter.go:178 msg="Build context" build_context="(go=go1.14.3, user=Homebrew, date=)" level=info ts=2020-10-08T10:46:06.899Z caller=node_exporter.go:105 msg="Enabled collectors" level=info ts=2020-10-08T10:46:06.899Z caller=node_exporter.go:112 collector=boottime level=info ts=2020-10-08T10:46:06.899Z caller=node_exporter.go:112 collector=cpu level=info ts=2020-10-08T10:46:06.899Z caller=node_exporter.go:112 collector=diskstats level=info ts=2020-10-08T10:46:06.899Z caller=node_exporter.go:112 collector=filesystem level=info ts=2020-10-08T10:46:06.899Z caller=node_exporter.go:112 collector=loadavg level=info ts=2020-10-08T10:46:06.899Z caller=node_exporter.go:112 collector=meminfo level=info ts=2020-10-08T10:46:06.899Z caller=node_exporter.go:112 collector=netdev level=info ts=2020-10-08T10:46:06.899Z caller=node_exporter.go:112 collector=textfile level=info ts=2020-10-08T10:46:06.901Z caller=node_exporter.go:112 collector=time level=info ts=2020-10-08T10:46:06.901Z caller=node_exporter.go:112 collector=uname level=info ts=2020-10-08T10:46:06.901Z caller=node_exporter.go:191 msg="Listening on" address=:9100 level=info ts=2020-10-08T10:46:06.901Z caller=tls_config.go:170 msg="TLS is disabled and it cannot be enabled on the fly." http2=false level=error ts=2020-10-08T10:46:06.902Z caller=node_exporter.go:194 err="listen tcp :9100: bind: address already in use" http://127.0.0.1:9100/metrics

    ╰─➤ vim /usr/local/etc/prometheus.yml global: scrape_interval: 15s scrape_configs: - job_name: "prometheus" static_configs: - targets: ["localhost:9090"] - job_name: "node" static_configs: - targets: ["127.0.0.1:9100"]

    参考:

    macOS安装GrafanaGrafana教程prometheus下载Homebrew安装prometheus1 Node Exporter for Prometheus Dashboard
    Processed: 0.010, SQL: 8