View Source Mete (mete v2.1.0)

[/miːt/] - Old English metan 'measure'

Basic measuring tool and telemetry writer using InfluxDB.

usage

Usage

Add Mete to your application by adding {:mete, "~> 2.1.0"} to your list of dependencies in mix.exs:

def deps do
  [
    # ...
    {:mete, "~> 2.1.0"}
  ]
end

options

Options

  • :host - hostname of the server running the InfluxDB endpoint, defaults to localhost
  • :port - port on which the InfluxDB server runs the respective input, defaults to 8089
  • :protocol - either :udp, or :http. Defaults to :udp.
  • :tags - can be used to configure application-wide tags expects a Keywordlist of strings or atoms, defaults to []
  • :batch - InfluxDB supports batching measurements, can be deactivated with false activated with true or directly configure the byte-size of the payloads with an integer
  • :compression - defaults to nil and can be set to :gzip only for http
  • :database - has to be configured when using :http (InfluxDB v1)
  • :bucket - bucket id for your target bucket (InfluxDB v2)
  • :organistaion - your organisation id (InfluxDB v2)
  • :token - your access token (InfluxDB v2)

example-for-influxdb-v2

Example for InfluxDB v2

  config :mete,
    influx_version: 2
    organisation: "ORGANISATION-ID",
    host: "some-cloud.influxdata.com",
    bucket: "BUCKET-ID",
    token: "YOUR-TOKEN",
    batch: 10_000
    path: "/api/v2/write",
    port: nil,
    protocol: :http,
    scheme: "https",

todo

ToDo

  • Configurable handling of integer/float values.
  • Configurable handling of timestamps
  • Support for mfa's for measure.
  • base default batch size on connection parameters

Link to this section Summary

Functions

Evaluates the given function, measures, and subsequently writes the elapsed real time.

Adds a meter point under the given atom to the process.

Reads the current process tags.

Alters the current process tags according the given keyword list.

Writes a single measurement. A measurement consists of a measurement, tags and fields.

Calculates the delta for the process meter points and writes them under the measurement.

Link to this section Types

Link to this section Functions

Link to this function

measure(measurement, tags \\ [], fields \\ [], func)

View Source
@spec measure(measurement(), tags(), fields() | [], (() -> any())) :: any()

Evaluates the given function, measures, and subsequently writes the elapsed real time.

iex> measure("query", fn -> "some query result" end)
"some query result"

Adds a meter point under the given atom to the process.

@spec tags() :: tags()

Reads the current process tags.

@spec tags(tags()) :: :ok

Alters the current process tags according the given keyword list.

The given keyword list will be merged into the existing tags, tags set to nil will remove that tag from the tag list.

Link to this function

write(measurement, tags \\ [], fields)

View Source
@spec write(measurement(), tags(), fields() | value()) :: :ok

Writes a single measurement. A measurement consists of a measurement, tags and fields.

Requires a name of the measurement either as a string or atom. Atoms are always converted to strings. Tags can be given either as a keyword list of strings or atoms, or tuple lists with string keys.

Fields can be either atoms, strings, boolean, integer, or floats. If measurements are not known to influx the according table will be created or altered. If a field should change its value from integer or float (or any other type) for some reason this will lead to datalos since the new fields wont match the present table.

examples

Examples:

iex> write("temp", [region: "EU", foo: "bar"], c: 42.0, f: 107.6)
:ok

If the value is without a name it defaults to :value thus ...

iex> write("temp", 42)
:ok

is equivalent to ...

iex> write("temp", value: 42)
:ok
Link to this function

write_meter(measurement, tags \\ [])

View Source

Calculates the delta for the process meter points and writes them under the measurement.