Skip to content

Yasumoto/Enpitsu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

import Foundation

let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .medium
dateFormatter.timeZone = TimeZone(abbreviation: "PDT")!

let client = Enpitsu(graphiteServer: "http://graphite.example.com:9001")
let metrics = try client.retrieveMetrics("collectd.*.servers.host-*.metricname")
for timeseries in metrics {
    print("Target: \(timeseries.target)")
    for datapoint in timeseries.datapoints {
        print(incidentDateFormatter.string(from: datapoint.date))
        print("\(value)")
    }
}