Download the PHP package lazyshot/prometheus-php without Composer

On this page you can find all versions of the php package lazyshot/prometheus-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package prometheus-php

PHP Client For Prometheus

An unofficial client for Prometheus (http://prometheus.io/) written in PHP. This fork is nearly identical to @TimeZynk fork except it includes a test script for both the counter and histogram. In addition a function for pushing the serialized client data to a prometheus push gateway with curl is provided. Lastly setup instructions for Prometheus, a Prometheus push gateway, and some example queries are provided with links.

Note It is strongly recommended that you read through some of the Prometheus documentation if you haven't already.

https://prometheus.io/docs/introduction/getting_started/

Requirements

A Prometheus server running on the localhost running with the provided .yml file. A Prometheus push gateway running on the localhost listening on port 9091. A php installation with the curl extension enabled... look up how to do this if you don't know.

Setup Prometheus

Lets launch the prometheus server so that it listens only to the push gateway that we will setup in the next step. We purposefully don't have prometheus listen to itself so it's easier to find the data we send to it later.

Prometheus is now running and is configured to pull from the localhost at port 9091. Let's give it something to pull!

Setup Prometheus Push Gateway

The Push Gateway allows short lived applications that would otherwise be a pain to try and pull data from to still be tracked. In addition it simplifies the task of sending the data we want to track to Prometheus at relatively minor cost. The prometheus documentation covers the advantages of PULL vs PUSH logging.

Push Gateway Link https://github.com/prometheus/pushgateway

Supported Metrics

Before explaining how to use the client it's important to understand what metrics the PHP client supports.

It's highly recommended to view the Prometheus documentations "Concepts => Data Model" to learn about the intricacies these metrics.

Using PHP Push Gateway Client

This fork has tried to simplify the process of using the client so that no outside libraries are required and everything should work right out of the box.

The only file that we need to include in order to start using the client is the Client.php.

Creating a new client is easy. Since the PHP client lives in the Prometheus namespace we must include that when creating a new client. In addition the client must be passed a list of options. Currently the only valid option is 'base_uri'. If you don't plan on using the built in "pushMetrics" function, you may set this to an empty string.

Next we tell the client to create a new metric. Here we are creating a new Counter.

We can use the new counter to increment different things. Here we pretend to be counting the status_codes returned by an imaginary server to clients for the "home.php" page.

Once we have gathered enough data we tell the client to send the metrics to the Prometheus Push Gateway. We can either send the data right to the gateway. Or we may specify a job, or a job and an instance of that job. The documentation at the Prometheus Push Gateway Git covers the specifics of what happens when setting jobs and instances and will not be covered here.

Here is the above code all in one snippet.

Going Further

Go ahead and run the /test/histogram_test.php function for a minute or two. The output is mundane so go get some coffee. Now you can navigate to the "http://localhost:9090/graph" in a web browser and execute the following query.

rate(meta_data_tv_elements_per_hit_sum[5m]) / rate(meta_data_tv_elements_per_hit_count[5m])

Adjust the graph to show over the past 15m. This is now a graph that would accurately show how many elements per hit an imaginary web scraper is pulling from from two different domains.

Just Serialized Data

If you want to see the data that is being sent to the server so you can expose it through a server or do whatever you wish you can simply call the serialize() function from the client.


All versions of prometheus-php with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lazyshot/prometheus-php contains the following files

Loading the files please wait ....