项目作者: Yasumoto

项目描述 :
Swift Graphite Client
高级语言: Swift
项目地址: git://github.com/Yasumoto/Enpitsu.git
创建时间: 2017-06-08T03:46:14Z
项目社区:https://github.com/Yasumoto/Enpitsu

开源协议:

下载


Enpitsu

A client for graphite-api, named after the Japanese word for pencil. This can also be used through Grafana if that is configured to pass through to Graphite as a datasource.

If there are dashboards configured in Grafana, one can also use this library to get a list of dashboards as well as the graphs on a dashboard.

Usage

  1. import Foundation
  2. let dateFormatter = DateFormatter()
  3. dateFormatter.dateStyle = .medium
  4. dateFormatter.timeStyle = .medium
  5. dateFormatter.timeZone = TimeZone(abbreviation: "PDT")!
  6. let client = Enpitsu(graphiteServer: "http://graphite.example.com:9001")
  7. let metrics = try client.retrieveMetrics("collectd.*.servers.host-*.metricname")
  8. for timeseries in metrics {
  9. print("Target: \(timeseries.target)")
  10. for datapoint in timeseries.datapoints {
  11. print(incidentDateFormatter.string(from: datapoint.date))
  12. print("\(value)")
  13. }
  14. }