Mobius (mobius v0.3.5) View Source
Localized metrics reporter
Link to this section Summary
Types
Arguments to Mobius
The name of the Mobius instance
Options to use when plotting time series metric data
Functions
Returns a specification to start this module under a supervisor.
Get the current metric information
Plot the metric name to the screen
Start Mobius
Produces a CSV of currently collected metrics, optionally writing the CSV to file. The CSV looks like: timestamp, name, type, value, tag1, tag2, tag3..., tagN If tags are provided, only the metrics matching the tags are output to the CSV. If a writable file is given via the :file option, the CSV is written to it. Otherwise it is written to the terminal. If the optional :naming option contains :csv_ext, the .csv extension is added to the file name if not already present. If the optional :naming option list :timestamp, the file name is prefixed by a timestamp.
Link to this section Types
Specs
arg() :: {:name, name()} | {:metrics, [Telemetry.Metrics.t()]} | {:persistence_dir, binary()}
Arguments to Mobius
:name
- the name of the mobius instance (defaults to:mobius
):metrics
- list of telemetry metrics for Mobius to track:persistence_dir
- the top level directory where mobius will persist metric information:day_count
- number of day-granularity samples to keep:hour_count
- number of hour-granularity samples to keep:minute_count
- number of minute-granularity samples to keep:second_count
- number of second-granularity samples to keep
Specs
Specs
metric_name() :: [atom()]
Specs
metric_type() :: :counter | :last_value | :sum
Specs
name() :: atom()
The name of the Mobius instance
This is used to store data for a particular set of mobius metrics.
Specs
naming_opt() :: :csv_ext | :timestamp
Specs
plot_opt() :: {:name, name()} | {:last, integer() | {integer(), time_unit()}} | {:from, integer()} | {:to, integer()} | {:type, metric_type()}
Options to use when plotting time series metric data
:name
- the name of the Mobius instance you are using. Unless you specified this in your configuration you should be safe to allow this option to default, which is:mobius_metrics
.:last
- display data point that have been captured over the lastx
amount of time. Wherex
is either an integer or a tuple of{integer(), time_unit()}
. If you only pass an integer the time unit of:seconds
is assumed. By default Mobius will plot the last 3 minutes of data.:from
- the unix timestamp, in seconds, to start querying from:to
- the unix timestamp, in seconds, to stop querying at:type
- for metrics that have different types of measurements, you can pass this option to filter which metric type you want to plot
Specs
time_unit() :: :second | :minute | :hour | :day
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Specs
info(name() | nil) :: :ok
Get the current metric information
If you configured Mobius to use a different name then you can pass in your custom name to ensure Mobius requests the metrics from the right place.
Specs
Plot the metric name to the screen
If there are tags for the metric you can pass those in the second argument:
Mobius.Charts.plot("vm.memory.total", %{some: :tag})
By default the plot will display the last 3 minutes of metric history.
However, you can pass the :from
and :to
options to look at a specific
range of time.
Mobius.plot("vm.memory.total", %{}, from: 1630619212, to: 1630619219)
You can also plot data over the last x
amount of time. Where x is an
integer. When there is no time_unit()
provided the unit is assumed to be
:second
.
Plotting data over the last 30 seconds:
Mobius.plot("vm.memory.total", %{}, last: 30)
Plotting data over the last 2 hours:
Mobius.plot("vm.memory.total", %{}, last: {2, :hour})
Start Mobius
Specs
Produces a CSV of currently collected metrics, optionally writing the CSV to file. The CSV looks like: timestamp, name, type, value, tag1, tag2, tag3..., tagN If tags are provided, only the metrics matching the tags are output to the CSV. If a writable file is given via the :file option, the CSV is written to it. Otherwise it is written to the terminal. If the optional :naming option contains :csv_ext, the .csv extension is added to the file name if not already present. If the optional :naming option list :timestamp, the file name is prefixed by a timestamp.
Just as with plotting, metrics to be outputted to CSV can be restricted to a relative time period:
:last
- metrics captured over the lastx
amount of time. Wherex
is either an integer or a tuple of{integer(), time_unit()}
. If you only pass an integer the time unit of:seconds
is assumed. By default the last 3 minutes of data will be outputted.:from
- the unix timestamp, in seconds, to start querying from:to
- the unix timestamp, in seconds, to stop querying at
If a metric has multiple types, a CSV can filter on one type with option type: :sum
or type: :last_value
etc..
Examples:
iex> Mobius.to_csv("vm.memory.total", %{})
-- writes CSV values to the terminal
iex> Mobius.to_csv("vm.memory.total", %{}, file: "/data/csv/vm.memory.total")
-- writes CSV values to file vm.memory.total
iex> Mobius.to_csv("vm.memory.total", %{}, file: "/data/csv/vm.memory.total", naming: [:csv_ext, :timestamp])
-- writes CSV values to a file like 20210830T174954_vm.memory.total.csv
iex> Mobius.to_csv("vm.memory.total", %{})
-- writes CSV values to the terminal
iex> Mobius.to_csv("vintage_net_qmi.connection.end.duration", %{ifname: "wwan0", status: :disconnected}, type: :sum, last: {60, :day})