SQL functions API Reference

This page is a reference for the functions available in Promscale.

General

NameArgumentsTypeDescription
add_prom_nodenode_name text, attach_to_existing_metrics DEFAULT trueboolean
config_maintenance_jobsnumber_jobs integer, new_schedule_interval interval, new_config jsonb DEFAULT NULL::jsonbbooleanConfigure the number of maintenance jobs run by the job scheduler, as well as their scheduled interval.
execute_maintenanceExecute maintenance tasks like dropping data according to retention policy. This procedure should be run regularly in a cron job.

Labels

NameArgumentsTypeDescription
eqlabels label_array, json_labels jsonbbooleaneq returns true if the labels and jsonb are equal, ignoring the metric name.
eqlabels1 label_array, labels2 label_arraybooleaneq returns true if two label arrays are equal, ignoring the metric name.
eqlabels1 label_array, matchers matcher_positivebooleaneq returns true if the label array and matchers are equal, there should not be a matcher for the metric name.
jsonblabels label_arrayjsonbjsonb converts a labels array to a JSONB object.
key_value_arraylabels label_array, OUT keys text[], OUT vals text[]recordkey_value_array converts a labels array to two arrays: one for keys and another for values.
label_cardinalitylabel_id integerinteger
label_key_positionmetric_name text, key textinteger
labelsseries_id bigintlabel_arraylabels fetches labels array for the given series id.
labels_infoINOUT labels integer[], OUT keys text[], OUT vals text[]recordlabels_info converts an array of label ids to three arrays: one for ids, one for keys and another for values.
matcherlabels jsonbmatcher_positivematcher returns a matcher for the JSONB, name is ignored. The matcher can be used to match against a label array using @> or ? operators.
vallabel_id integertextval returns the label value from a label id.

Metrics

NameArgumentsTypeDescription
drop_metricmetric_name_to_be_dropped textvoid
delete_series_from_metricmetric_name text, series_idsbooleandeletes the series from the metric.
get_default_metric_retention_periodintervalReturns the current default retention period for metrics.
get_metric_metadatametric_family_nametextTABLE(metric_family text, type text, unit text, help text)
get_metric_retention_periodmetric_name textintervalReturns the retention period configured for a specific metric.
get_multiple_metric_metadatametric_families text[]TABLE(metric_family text, type text, unit text, help text)
is_normal_nanvalue double precisionbooleanis_normal_nan returns true if the value is a NaN.
is_stale_markervalue double precisionbooleanis_stale_marker returns true if the value is a Prometheus stale marker.
register_metric_viewschema_name text, view_name text, if_not_exists booleanbooleanRegister metric view with Promscale. This enables you to query the data with PromQL and set data retention policies through Promscale. Schema name and view name should be set to the desired schema and view you want to use. Note: underlying view needs to be based on an existing metric in Promscale (should use its table in the FROM clause).
reset_metric_chunk_intervalmetric_name textbooleanreset_metric_chunk_interval resets the chunk interval for a specific metric to using the default.
reset_metric_compression_settingmetric_name textbooleanreset_metric_compression_setting resets the compression setting for a specific metric to using the default.
reset_metric_retention_periodmetric_name textbooleanreset_metric_retention_period resets the retention period for a specific metric to using the default.
set_compression_on_metric_tablemetric_table_name text, compression_setting booleanvoidset_compression_on_metric_table set a compression for a specific metric table.
set_default_chunk_intervalchunk_interval intervalbooleanset_default_chunk_interval set the chunk interval for any metrics (existing and new) without an explicit override.
set_default_compression_settingcompression_setting booleanbooleanset_default_compression_setting set the compression setting for any existing and new metrics without an explicit override.
set_default_retention_periodretention_period intervalbooleanset_default_retention_period set the retention period for any metrics (existing and new) without an explicit override.
set_metric_chunk_intervalmetric_name text, chunk_interval intervalbooleanset_metric_chunk_interval set a chunk interval for a specific metric (this overrides the default).
set_metric_compression_settingmetric_name text, new_compression_setting booleanbooleanset_metric_compression_setting set a compression setting for a specific metric and this overrides the default.
set_metric_retention_periodmetric_name text, new_retention_period intervalbooleanset_metric_retention_period set a retention period for a specific metric (this overrides the default).
unregister_metric_viewschema_name text, view_name text, if_not_exists booleanbooleanUnregister metric view with Promscale. Schema name and view name should be set to the metric view already registered in Promscale.