class Redis extends AbstractStorage

Class Redis Storage implementation using Redis.

Methods

__construct(string $host, null|string $password = null, int $port = 6379, string $prefix = 'PHPProm:', null|string $dbIndex = null)

Redis constructor.

addAvailableMetric(string $metric, string $label, string $help, string $type, string $defaultValue)

Adds a metric to the available ones.

array
getAvailableMetrics()

Gets all available metrics in an array.

void
storeMeasurement(string $metric, string $key, float $value)

Stores a measurement.

void
incrementMeasurement(string $metric, string $key)

Increments a measurement, starting with 1 if it doesn't exist yet.

array
getMeasurements(string $metric, array $keys, string $defaultValue = 'Nan')

Gets all measurements.

Details

at line line 41
__construct(string $host, null|string $password = null, int $port = 6379, string $prefix = 'PHPProm:', null|string $dbIndex = null)

Redis constructor.

Parameters

string $host the connection host
null|string $password the password for authentication, null to ignore
int $port the connection port, default 6379
string $prefix the global key prefix to use, default 'PHPProm:'
null|string $dbIndex the Redis DB index to use, null to ignore

in AbstractStorage at line line 48
addAvailableMetric(string $metric, string $label, string $help, string $type, string $defaultValue)

Adds a metric to the available ones.

Parameters

string $metric the metric itself as delivered by Prometheus
string $label the name of the one Prometheus label to categorize the values
string $help a helping text for the metric
string $type the Prometheus type of the metric
string $defaultValue the default value which the metric gets if there is no value stored

in AbstractStorage at line line 64
array getAvailableMetrics()

Gets all available metrics in an array.

Return Value

array the available metrics

at line line 57
void storeMeasurement(string $metric, string $key, float $value)

Stores a measurement.

Parameters

string $metric the name of the metric
string $key the key
float $value the value

Return Value

void

at line line 64
void incrementMeasurement(string $metric, string $key)

Increments a measurement, starting with 1 if it doesn't exist yet.

Parameters

string $metric the name of the metric
string $key the key

Return Value

void

at line line 71
array getMeasurements(string $metric, array $keys, string $defaultValue = 'Nan')

Gets all measurements.

Parameters

string $metric the name of the metric
array $keys the keys to retrieve
string $defaultValue the default value a key gets if there is no value for it in the storage

Return Value

array the map with the keys and values