Skip to content
This repository was archived by the owner on Mar 19, 2020. It is now read-only.

Repository files navigation

PApi - PHP Api client library for Prometheus

Build Status

Targets to provide simple means for obtaining data from Prometheus API.

Stable for Prometheus 1.x and <= v2.2 api spec NOTICE: some endpoints are only available in newer versions of Prometheus. For detailed list see table of available calls below.

Instalation

Use composer to add PApi as dependency:

$ composer install cdn77/papi

Usage

Create a client

<?php
use PApi\Client;
require __DIR__ . '/vendor/autoload.php';
$client = new Client([
'host' => 'my-prometheus.com',
]);

Available options

NameDefault valueDescription
schemehttpHost scheme
hostlocalhostHost address
port9090Host port
path/api/v1/Path to base API endpoint
timeout30Timeout for requests
usernamenullHTTP Auth username
passwordnullHTTP Auth password
connectionHeaders[]Connection headers
connectionTypeCurlConnection::classClass to use for connection. See below

Available connection classes

  • CurlConnection - pure php curl implementation. Used by default.
  • GuzzleConnection - using guzzle 6.3+ library.

Available calls

PApi currently has methods for all available endpoints provided by Prometheus.

CallCodePrometheus compatibilityOfficial doc
Query$client->getQuery('up', new \DateTimeImmutable('now');>=1.0doc
QueryRange$client->getQueryRange('up', new \DateTimeImmutable('today'), new \DateTimeImmutable('now'), '12h');>=1.0doc
Series$client->getSeries(['up'], new \DateTimeImmutable('-1 minute'), new \DateTimeImmutable('now');>=1.0doc
Label Values$client->getLabelValues('job');>=1.0doc
Targets (active only)$client->getTargets();>=1.0doc
Alert Managers$client->getAlertManagers();>=1.0doc
Create snapshot$client->createSnapshot();>=2.1doc
Delete series$client->deleteSeries(['up'], new DateTimeImmutable('today'), new DateTimeImmutable('now');>=2.1doc
Clean tombstones$client->cleanTombstones();>=2.1doc
Get Config$client->getConfig();>=2.2doc
Get Flags$client->getFlags();>=2.2doc

About

(Abandoned) PApi - PHP Api client library for Prometheus

Resources

Stars

5 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages