metrics

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 4 Imported by: 0

README

Metrics

来源

Grafana

浏览器:localhost:3000

docker run --name grafana -d -p 3000:3000 grafana/grafana

Prometheus

浏览器:localhost:9090

docker run -d --name prometheus -p 9090:9090 -v ~/tmp/prometheus.yml:/etc/prometheus/prometheus.yml \
              prom/prometheus
              
# Dashboard JSON
# metrics/prometheus/grafana.json

配置文件deployments/configs/prometheus.yml

global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.
  evaluation_interval: 15s # Evaluate rules every 15 seconds.

  # Attach these extra labels to all timeseries collected by this Prometheus instance.
  external_labels:
    monitor: 'codelab-monitor'

rule_files:
  - 'prometheus.rules.yml'

scrape_configs:
  - job_name: 'prometheus'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:9090']

  - job_name:       'select_web'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['www.localhost.com']
        labels:
          group: 'production'

Push模式

Graphite

浏览器:localhost:8090

# 登录账户名:root,密码:root
docker run -d --name graphite --restart=always -p 8090:80 -p 2003-2004:2003-2004 -p 2023-2024:2023-2024 -p 8125:8125/udp -p 8126:8126 hopsoft/graphite-statsd

# Dashboard JSON
# middleware/metrics/grafana_graphite.json
InfluxDB

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(options ...Option) *Metrics

NewMetrics creates a new Metrics

func (*Metrics) GetRegistry

func (m *Metrics) GetRegistry() metrics.Registry

func (*Metrics) Graphite

func (m *Metrics) Graphite(freq time.Duration, prefix string, addr *net.TCPAddr)

Graphite reports metrics into graphite.// // addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003")// m.Graphite(10e9, "metrics", addr)//

func (*Metrics) InfluxDB

func (m *Metrics) InfluxDB(freq time.Duration, url, database, username, password string)

InfluxDB reports metrics into influxdb.// // m.InfluxDB(10e9, "http://127.0.0.1:8086","metrics", "test","test"})//

func (*Metrics) InfluxDBWithTags

func (m *Metrics) InfluxDBWithTags(freq time.Duration, url, database, username, password string, tags map[string]string)

InfluxDBWithTags reports metrics into influxdb with tags.// you can set node info into tags.// // m.InfluxDBWithTags(10e9, "http://127.0.0.1:8086","metrics", "test","test", map[string]string{"host":"127.0.0.1"})//

func (*Metrics) Log

func (m *Metrics) Log(freq time.Duration, l metrics.Logger)

Log reports metrics into logs.// // m.Log(30*time.Second, e.Logger)//

func (*Metrics) MemStats

func (m *Metrics) MemStats()

func (*Metrics) WithPrefix

func (m *Metrics) WithPrefix(s string) string

type Option

type Option func(c *Options)

func Prefix

func Prefix(p string) Option

func Registry

func Registry(r metrics.Registry) Option

type Options

type Options struct {
	Registry metrics.Registry
	Prefix   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL