You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-3Lines changed: 37 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,8 @@ If using Redis, we recommend running a local Redis instance next to your PHP wor
9
9
## How does it work?
10
10
11
11
Usually PHP worker processes don't share any state.
12
-
You can pick from four adapters.
13
-
Redis, APC, APCng, or an in-memory adapter.
12
+
You can pick from five adapters.
13
+
Redis, Predis, APC, APCng, or an in-memory adapter.
14
14
While the first needs a separate binary running, the second and third just need the [APC](https://pecl.php.net/package/APCU) extension to be installed. If you don't need persistent metrics between requests (e.g. a long running cron job or script) the in-memory adapter might be suitable to use.
Change the Redis options (the example shows the defaults):
78
+
74
79
```php
75
80
\Prometheus\Storage\Redis::setDefaultOptions(
76
81
[
@@ -84,7 +89,23 @@ Change the Redis options (the example shows the defaults):
84
89
);
85
90
```
86
91
92
+
Using the Predis storage (requires `predis/predis`):
93
+
94
+
```php
95
+
$registry = new CollectorRegistry(new \Prometheus\Storage\Predis());
96
+
```
97
+
98
+
Or with an existing connection:
99
+
100
+
```php
101
+
$client = new \Predis\Client(['host' => '127.0.0.1']);
102
+
$registry = new CollectorRegistry(\Prometheus\Storage\Predis::fromExistingConnection($client));
103
+
```
104
+
105
+
> **Note:** Using `Redis::setPrefix()` and `Predis::setPrefix()` share the same prefix. Using both adapters with different prefixes in the same application is not supported.
106
+
87
107
Using the InMemory storage:
108
+
88
109
```php
89
110
$registry = new CollectorRegistry(new InMemory());
$registry = new CollectorRegistry(new \PDO('mysql:host=localhost;dbname=prometheus', 'username', 'password'));
109
133
or
@@ -113,11 +137,13 @@ $registry = new CollectorRegistry(new \PDO('sqlite::memory:'));
113
137
### Advanced Usage
114
138
115
139
#### Advanced Histogram Usage
140
+
116
141
On passing an empty array for the bucket parameter on instantiation, a set of default buckets will be used instead.
117
142
Whilst this is a good base for a typical web application, there is named constructor to assist in the generation of
118
143
exponential / geometric buckets.
119
144
120
145
Eg:
146
+
121
147
```
122
148
Histogram::exponentialBuckets(0.05, 1.5, 10);
123
149
```
@@ -127,7 +153,9 @@ This will start your buckets with a value of 0.05, grow them by a factor of 1.5
127
153
Also look at the [examples](examples).
128
154
129
155
#### PushGateway Support
130
-
As of Version 2.0.0 this library doesn't support the Prometheus PushGateway anymore because we want to have this package as small als possible. If you need Prometheus PushGateway support, you could use the companion library: https://github.com/PromPHP/prometheus_push_gateway_php
156
+
157
+
As of Version 2.0.0 this library doesn't support the Prometheus PushGateway anymore because we want to have this package as small als possible. If you need Prometheus PushGateway support, you could use the companion library: <https://github.com/PromPHP/prometheus_push_gateway_php>
0 commit comments