Instream v0.18.0 Instream.Series behaviour View Source

Defines a series.

Usage

defmodule MySeries do
  use Instream.Series

  series do
    database    "my_database_optional"
    measurement "cpu_load"

    tag :host, default: "www"
    tag :core

    field :value, default: 100
    field :value_desc
  end
end

Metadata

The metadata of a series (e.g. the measurement) can be retrieved using the __meta__/1 method.

Struct

Every series will be registered as a struct. Following the above usage example you will get the following struct:

%MySeries{
  fields:    %MySeries.Fields{ value: 100, value_desc: nil },
  tags:      %MySeries.Tags{ host: "www", core: nil },
  timestamp: nil
}

:timestamp is expected to be a unix nanosecond timestamp.

Link to this section Summary

Functions

Defines the database for the series

Defines a field in the series

Defines the measurement of the series

Defines the series

Defines a tag in the series

Callbacks

Provides metadata access for a series

Creates a series dataset from any given map

Creates a list of series datasets from a query result map

Link to this section Functions

Link to this macro database(name) View Source (macro)

Defines the database for the series.

Link to this macro field(name, opts \\ []) View Source (macro)

Defines a field in the series.

Link to this macro measurement(name) View Source (macro)

Defines the measurement of the series.

Defines the series.

Link to this macro tag(name, opts \\ []) View Source (macro)

Defines a tag in the series.

Link to this section Callbacks

Link to this callback __meta__(atom) View Source
__meta__(atom()) :: any()

Provides metadata access for a series.

Available information

  • :database - the database where the series is stored (optional)
  • :fields - the fields in the series
  • :measurement - the measurement of the series
  • :tags - the available tags defining the series
Link to this callback from_map(map) View Source
from_map(map()) :: struct()

Creates a series dataset from any given map.

Keys not defined in the series are silently dropped.

Link to this callback from_result(map) View Source
from_result(map()) :: [struct()]

Creates a list of series datasets from a query result map.

Keys not defined in the series are silently dropped.