InfluxEx.Point (influx_ex v0.1.1)

A single data point

Link to this section Summary

Functions

Add many fields at once

Add a tag to your point

Add many tags to your point at once

Make a new point for a measurement

Turn the point into the line protocol format expected by the InfluxDB

Link to this section Types

@type opt() :: {:timestamp, integer()} | {:precision, System.time_unit()}
@type t() :: %InfluxEx.Point{
  fields: map(),
  measurement: InfluxEx.measurement(),
  precision: System.time_unit(),
  tags: map(),
  timestamp: integer()
}

Link to this section Functions

Link to this function

add_field(point, field_name, field_value)

@spec add_field(t(), binary() | atom(), integer()) :: t()

Add field to the point

Fields are the values you want to track over time. You can think of these as the metric values.

"cpu"
|> InfluxEx.Point.new()
|> InfluxEx.Point.add_field("avg", 5)

The above point is for the average CPU usage.

A single point can container many fields.

"cpu"
|> InfluxEx.Point.new()
|> InfluxEx.Point.add_field("avg", 5)
|> InfluxEx.Point.add_field("last_reading", 10)

If you have all the measurements at once you can use InfluxEx.Point.add_fields/2.

Link to this function

add_fields(point, fields)

@spec add_fields(t(), map()) :: t()

Add many fields at once

"cpu"
|> InfluxEx.Point.new()
|> InfluxEx.Point.add_fields(%{avg: 5, last_reading: 10})
Link to this function

add_tag(point, tag_name, tag_value)

@spec add_tag(t(), atom() | binary(), binary()) :: t()

Add a tag to your point

Tags are meta data about your point. For example, maybe the location of a device you are reading data from.

"cpu"
|> InfluxEx.Point.new()
|> InfluxEx.Point.add_tag(:location, "EU")

You can add many tags at once using InfluxEx.Point.add_tags/2

Link to this function

add_tags(point, tags)

@spec add_tags(t(), map()) :: t()

Add many tags to your point at once

Tags are meta data about your point. For example, maybe the location of a device you are reading data from.

"cpu"
|> InfluxEx.Point.new()
|> InfluxEx.Point.add_tags(%{location: "EU", product: "Awesome Product"})

You can add many tags at once using InfluxEx.Point.add_tags/2

Link to this function

new(measurement, opts \\ [])

@spec new(InfluxEx.measurement(), [opt()]) :: t()

Make a new point for a measurement

InfluxEx.Point.new("cpu")
Link to this function

to_line_protocol(point)

Turn the point into the line protocol format expected by the InfluxDB