InfluxEx.Point (influx_ex v0.3.1)
A single data point
Link to this section Summary
Functions
Add field to the point
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
opt()
@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
add_field(point, field_name, field_value, opts \\ [])
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
.
add_fields(point, fields)
Add many fields at once
"cpu"
|> InfluxEx.Point.new()
|> InfluxEx.Point.add_fields(%{avg: 5, last_reading: 10})
add_tag(point, tag_name, tag_value)
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
add_tags(point, tags)
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
new(measurement, opts \\ [])
@spec new(InfluxEx.measurement(), [opt()]) :: t()
Make a new point for a measurement
InfluxEx.Point.new("cpu")
to_line_protocol(point)
Turn the point into the line protocol format expected by the InfluxDB