klio.metrics.stackdriver

Klio ships with a Stackdriver Log-based Metrics relay client. The client creates metrics objects in Stackdriver Monitoring based off of filters in Stackdriver Logging. For more information on Stackdriver’s Log-based Metrics, see related documentation.

When running on Dataflow, the client is on by default with no additional configuration needed. This must be actively turned off in klio-job.yaml if not wanted (see below).

The log-based metrics client is not available for direct runner.

To explicitly turn off log-based metrics, in klio-job.yaml:

job_config:
  metrics:
    stackdriver_logger: false

Deprecated since version 21.3.0: Use native metrics instead. See docs for more info.

class klio.metrics.stackdriver.StackdriverLogMetricsClient(**kwargs)

Stackdriver client for transform metrics.

Intended to be instantiated by klio.metrics.client.MetricsRegistry and not by itself.

Parameters

klio_config (klio_core.config.KlioConfig) – the job’s configuration.

Deprecated since version 21.3.0: Use NativeMetricsClient instead. See docs for more info.

counter(name, transform=None, tags=None, **kwargs)

Create a StackdriverLogMetricsCounter object.

Note

Stackdriver counts log lines so initializing a counter value is not supported .

Parameters
  • name (str) – name of counter

  • transform (str) – transform the counter is associated with

  • tags (dict) – any tags of additional contextual information to associate with the counter

Returns

a log-based counter

Return type

StackdriverLogMetricsCounter

gauge(*args, **kwargs)

Create a StackdriverLogMetricsGauge object.

Warning

Gauges for Stackdriver are not yet supported. This will default to standard logging.

Parameters
  • name (str) – name of gauge

  • value (int) – starting value of gauge; defaults to 0

  • transform (str) – transform the gauge is associated with

  • tags (dict) – any tags of additional contextual information to associate with the gauge

Returns

a log-based gauge

Return type

StackdriverLogMetricsGauge

timer(*args, **kwargs)

Create a StackdriverLogMetricsTimer object.

Warning

Timers for Stackdriver are not yet supported. This will default to standard logging.

Parameters
  • name (str) – name of gauge

  • value (int) – starting value of gauge; defaults to 0

  • transform (str) – transform the gauge is associated with

  • tags (dict) – any tags of additional contextual information to associate with the gauge

Returns

a log-based timer

Return type

StackdriverLogMetricsTimer

class klio.metrics.stackdriver.StackdriverLogMetricsCounter(**kwargs)

Stackdriver log-based counter metric.

Note

Stackdriver counts log lines so initializing a counter value is not supported .

Parameters
  • name (str) – name of counter

  • job_name (str) – name of Dataflow job

  • project (str) – name of GCP project associated with Dataflow job

  • transform (str) – Name of transform associated with counter, if any.

  • tags (dict) – Tags to associate with counter. Note: {"metric_type": "counter"} will always be an included tag.

Deprecated since version 21.3.0: Use NativeCounter instead. See docs for more info.

class klio.metrics.stackdriver.StackdriverLogMetricsGauge(**kwargs)

Pass-thru object for naming only. Stackdriver log-based metrics does not support gauges.

Deprecated since version 21.3.0: Use NativeGauge instead. See docs for more info.

class klio.metrics.stackdriver.StackdriverLogMetricsTimer(**kwargs)

Pass-thru object for naming only. Stackdriver log-based metrics does not support timers.

Deprecated since version 21.3.0: Use NativeTimer instead. See docs for more info.