Skip to content

Recognos/Metrics.NET.InfluxDB

Repository files navigation

Metrics.NET.InfluxDB

InfluxDB reporter integration for Metrics.NET.

Current version: v0.5.0-pre

This library provides support for InfluxDB reporters using the Metrics.NET monitoring and reporting library.

Supports InfluxDB Line Protocol for InfluxDB v0.9.1 and above. Supports InfluxDB JSON Protocol for InfluxDB v0.9.1 and below.

The JSON protocol, which was previously used by the InfluxDB reporter, has been deprecated and removed in InfluxDB versions greater than v0.9.1. The expected way to write metric data to InfluxDB after this point is by using the LineProtocol syntax defined in the InfluxDB docs.

This library adds support for the newer versions of InfluxDB which use the line protocol syntax and supports both the HTTP and UDP protocols.

More documentation is availale in the wiki.

Changelog

Metrics.NET Repository

Configuration

Configuration can be done using the different overloads of the MetricsReports configuration object. For example, the following code will add an InfluxDB reporter using the HTTP protocol for a database named testdb on host 10.0.10.24:80:

Metric.Config
	.WithReporting(report => report
		.WithInfluxDbHttp("10.0.10.24", "testdb", reportInterval, null, c => c
			.WithConverter(new DefaultConverter().WithGlobalTags("host=web1,env=dev"))
			.WithFormatter(new DefaultFormatter().WithLowercase(true))
			.WithWriter(new InfluxdbHttpWriter(c, 1000))));

Extensibility

The InfluxDB report has been refactored to separate the writing process into a separate InfluxdbWriter which is responsible for writing the data using the whichever protocol is chosen. This also allows extending the model to support other or future types of protocols and formats defined by InfluxDB.

Writing data to InfluxDB is done in 3 different and extendable steps:

  • InfluxdbConverter: Converts the metric data into InfluxRecords, which are the data model object for InfluxDB datapoints.
  • InfluxdbFormatter: Formats the metric name and tag/field names used in the InfluxDB tables. For example, this can convert all names to lowercase or replace any spaces with underscores.
  • InfluxdbWriter: Writes the InfluxRecords to the database. Derived implementations exist for the HTTP and UDP protocols.

Building

NOTE: All build scripts must be run from the repository root.

Run build.bat to compile and test the Metrics.InfluxDB.dll assmebly. Output gets copied to the .\bin\ directory.

Run create-nuget.bat to build the solution and create a nuget .nupkg package in the .\Publishing\ directory.

License

This library will keep the same license as the main Metrics.NET project.

The main metrics project is released under the terms: Copyright (c) 2016 The Recognos Metrics.NET Team Published under Apache Software License 2.0, see LICENSE

This library (Metrics.NET.InfluxDB) is released under the Apache 2.0 License (see LICENSE) Copyright (c) 2016 Jason O'Bryan, The Recognos Metrics.NET Team

About

InfluxDB reporter for Metrics.NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages