metrics command

The metrics command allows you to query the metric endpoints of the Microsegmentation Console API.

instant subcommand

The instant subcommand allows you to query the Prometheus compatible instant metrics endpoint of the Microsegmentation Console API. This upstream API is simply a wrapper over the standard Prometheus instant query API and follows the same query semantics. Documentation for the API can be found at https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries.
You must supply a valid PromQL (Prometheus Query Language) expression as the first parameter to the command. The supplied PromQL expression must contain a namespace label with an appropriate value in order for your query to pass authorization.

Authorizing queries

The Microsegmentation Console will verify that you are authorized to run the query by checking the value of the namespace label in the provided PromQL expression. An error will be returned by the API if you are not authorized to run the supplied PromQL expression against the configured namespace or if the namespace label is absent. As a result of this, all time-series selectors in your PromQL expression must contain the namespace label.

Valid time-series selectors

The flows time-series tracks the accepted/rejected flows on a given namespace and contains the following labels:

Performing recursive namespace queries

This is simply a matter of providing a regular expression label matcher for the namespace label.
Example:
apoctl metrics instant 'flows{namespace=~"/my/namespace.*"}[1h]'

Query evaluation timestamp

The evaluation time of the supplied PromQL expression can be configured with the flags --timestamp or --timestamp-rel.

Supplying an absolute query evaluation timestamp

This can be achieved using the --timestamp flag which takes a single string parameter representing a supported date format.
apoctl metrics instant 'flows{namespace=~"/my/namespace.*"}[1h]' --timestamp 2018-01-01
The complete list of supported date formats is described at https://github.com/araddon/dateparse.

Supplying a relative query evaluation timestamp

This can be achieved using the --timestamp-rel flag which takes a single string parameter representing a valid Go(lang) duration.
apoctl metrics instant 'flows{namespace=~"/my/namespace.*"}[1h]' --timestamp-rel 1h

Displaying results

By default, the instant command displays the results in a table. If you want to see the raw JSON response, you can use the flag --output.
Example:
apoctl metrics instant 'flows{namespace=~"/my/namespace.*"}[1h]' --timestamp-rel 1h --output json

Help

apoctl metrics instant -h

range subcommand

The range subcommand allows you to query the Prometheus compatible range metrics endpoint of the Microsegmentation Console API. This upstream API is simply a wrapper over the standard Prometheus range query API and follows the same query semantics. Documentation for the API can be found at https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries.
You must supply a valid PromQL (Prometheus Query Language) expression as the first parameter to the command. The supplied PromQL expression must contain a namespace label with an appropriate value in order for your query to pass authorization.

Authorizing queries

The Microsegmentation Console will verify that you are authorized to run the query by checking the value of the namespace label in the provided PromQL expression. An error will be returned by the API if you are not authorized to run the supplied PromQL expression against the configured namespace or if the namespace label is absent. As a result of this, all time-series selectors in your PromQL expression must contain the namespace label.

Valid time-series selectors

The flows time-series tracks the accepted/rejected flows on a given namespace and contains the following labels:

Required flags

The --step flag represents the query resolution step width in Go(lang) duration format.

Performing recursive namespace queries

This is simply a matter of providing a regular expression label matcher for the namespace label.
Example:
apoctl metrics range 'flows{namespace=~"/my/namespace.*"}[1h]' --step 10m --start-rel 24h

Defining a time window for your query

The time window of your range query can be configured either using relative or absolute timestamps with the following flags:

Supplying an absolute query evaluation time window

apoctl metrics range 'flows{namespace=~"/my/namespace.*"}[1h]' --step 10m --start 2018-01-01 --end 2018-02-02
The complete list of supported date formats is described at https://github.com/araddon/dateparse.

Supplying a relative query evaluation time window

apoctl metrics range 'flows{namespace=~"/my/namespace.*"}[1h]' --step 10m --start-rel 24h --end-rel 1h

Displaying results

By default, the range command displays the results in a table. If you want to see the raw JSON response, you can use the flag --output.
Example:
apoctl metrics range 'flows{namespace=~"/my/namespace.*"}[1h]' --step 10m --start-rel 1h --output json

Help

apoctl metrics range -h

Recommended For You