@@ -9,19 +9,19 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
9
9
10
10
# Monitoring.
11
11
12
- Enqueue provides a tool for monitoring message queues.
12
+ Enqueue provides a tool for monitoring message queues.
13
13
With it, you can control how many messages were sent, how many processed successfuly or failed.
14
- How many consumers are working, their up time, processed messages stats, memory usage and system load.
14
+ How many consumers are working, their up time, processed messages stats, memory usage and system load.
15
15
The tool could be integrated with virtually any analytics and monitoring platform.
16
- There are several integration:
16
+ There are several integration:
17
17
* [ Datadog StatsD] ( https://datadoghq.com )
18
18
* [ InfluxDB] ( https://www.influxdata.com/ ) and [ Grafana] ( https://grafana.com/ )
19
- * [ WAMP (Web Application Messaging Protocol)] ( https://wamp-proto.org/ )
19
+ * [ WAMP (Web Application Messaging Protocol)] ( https://wamp-proto.org/ )
20
20
We are working on a JS\WAMP based real-time UI tool, for more information please
[ contact us
] ( [email protected] ) .
21
21
22
22
![ Grafana Monitoring] ( images/grafana_monitoring.jpg )
23
23
24
- [ contact us
] ( [email protected] ) if need a Grafana template such as on the picture.
24
+ [ contact us
] ( [email protected] ) if need a Grafana template such as on the picture.
25
25
26
26
* [ Installation] ( #installation )
27
27
* [ Track sent messages] ( #track-sent-messages )
@@ -40,7 +40,7 @@ We are working on a JS\WAMP based real-time UI tool, for more information please
40
40
composer req enqueue/monitoring:0.9.x-dev
41
41
```
42
42
43
- ## Track sent messages
43
+ ## Track sent messages
44
44
45
45
``` php
46
46
<?php
@@ -50,7 +50,7 @@ use Enqueue\Monitoring\GenericStatsStorageFactory;
50
50
$statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1:8086?db=foo');
51
51
$statsStorage->pushSentMessageStats(new SentMessageStats(
52
52
(int) (microtime(true) * 1000), // timestamp
53
- 'queue_name', // queue
53
+ 'queue_name', // queue
54
54
'aMessageId',
55
55
'aCorrelationId',
56
56
[], // headers
@@ -76,7 +76,7 @@ $context->createProducer()->send($queue, $message);
76
76
$statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1:8086?db=foo');
77
77
$statsStorage->pushSentMessageStats(new SentMessageStats(
78
78
(int) (microtime(true) * 1000),
79
- $queue->getQueueName(),
79
+ $queue->getQueueName(),
80
80
$message->getMessageId(),
81
81
$message->getCorrelationId(),
82
82
$message->getHeaders()[],
@@ -99,7 +99,7 @@ $statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1
99
99
$statsStorage->pushConsumedMessageStats(new ConsumedMessageStats(
100
100
'consumerId',
101
101
(int) (microtime(true) * 1000), // now
102
- $receivedAt,
102
+ $receivedAt,
103
103
'aQueue',
104
104
'aMessageId',
105
105
'aCorrelationId',
@@ -127,16 +127,16 @@ $consumer = $context->createConsumer($queue);
127
127
$consumerId = uniqid('consumer-id', true); // we suggest using UUID here
128
128
if ($message = $consumer->receiveNoWait()) {
129
129
$receivedAt = (int) (microtime(true) * 1000);
130
-
130
+
131
131
// heavy processing here.
132
-
132
+
133
133
$consumer->acknowledge($message);
134
-
134
+
135
135
$statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1:8086?db=foo');
136
136
$statsStorage->pushConsumedMessageStats(new ConsumedMessageStats(
137
137
$consumerId,
138
138
(int) (microtime(true) * 1000), // now
139
- $receivedAt,
139
+ $receivedAt,
140
140
$queue->getQueueName(),
141
141
$message->getMessageId(),
142
142
$message->getCorrelationId(),
@@ -151,7 +151,7 @@ if ($message = $consumer->receiveNoWait()) {
151
151
## Track consumer metrics
152
152
153
153
Consumers are long running processes. It vital to know how many of them are running right now, how they perform, how much memory do they use and so.
154
- This example shows how you can send such metrics.
154
+ This example shows how you can send such metrics.
155
155
Call this code from time to time between processing messages.
156
156
157
157
``` php
@@ -165,13 +165,13 @@ $statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1
165
165
$statsStorage->pushConsumerStats(new ConsumerStats(
166
166
'consumerId',
167
167
(int) (microtime(true) * 1000), // now
168
- $startedAt,
168
+ $startedAt,
169
169
null, // finished at
170
- true, // is started?
170
+ true, // is started?
171
171
false, // is finished?
172
172
false, // is failed
173
173
['foo'], // consume from queues
174
- 123, // received messages
174
+ 123, // received messages
175
175
120, // acknowledged messages
176
176
1, // rejected messages
177
177
1, // requeued messages
@@ -182,7 +182,7 @@ $statsStorage->pushConsumerStats(new ConsumerStats(
182
182
183
183
## Consumption extension
184
184
185
- There is an extension ` ConsumerMonitoringExtension ` for Enqueue [ QueueConsumer] ( quick_tour.md#consumption ) .
185
+ There is an extension ` ConsumerMonitoringExtension ` for Enqueue [ QueueConsumer] ( quick_tour.md#consumption ) .
186
186
It could collect consumed messages and consumer stats for you.
187
187
188
188
``` php
@@ -236,8 +236,16 @@ There are available options:
236
236
* 'measurementSentMessages' => 'sent-messages',
237
237
* 'measurementConsumedMessages' => 'consumed-messages',
238
238
* 'measurementConsumers' => 'consumers',
239
+ * 'client' => null,
240
+ * 'retentionPolicy' => null,
239
241
```
240
242
243
+ You can pass InfluxDB\Client instance in ` client ` option. Otherwise, it will be created on first use according to other
244
+ options.
245
+
246
+ If your InfluxDB\Client uses driver that implements InfluxDB\Driver\QueryDriverInterface, then database will be
247
+ automatically created for you if it doesn't exist. Default InfluxDB\Client will also do that.
248
+
241
249
## Datadog storage
242
250
243
251
Install additional packages:
@@ -256,7 +264,7 @@ $statsStorage = (new GenericStatsStorageFactory())->create('datadog://127.0.0.1:
256
264
For best experience please adjust units and types in metric summary.
257
265
258
266
Example dashboard:
259
-
267
+
260
268
![ Datadog monitoring] ( images/datadog_monitoring.png )
261
269
262
270
@@ -311,7 +319,7 @@ There are available options:
311
319
312
320
## Symfony App
313
321
314
- You have to register some services in order to incorporate monitoring facilities into your Symfony application.
322
+ You have to register some services in order to incorporate monitoring facilities into your Symfony application.
315
323
316
324
``` yaml
317
325
# config/packages/enqueue.yaml
@@ -325,11 +333,11 @@ enqueue:
325
333
transport : ' amqp://guest:guest@foo:5672/%2f'
326
334
monitoring : ' wamp://127.0.0.1:9090?topic=stats'
327
335
client : ~
328
-
336
+
329
337
datadog :
330
338
transport : ' amqp://guest:guest@foo:5672/%2f'
331
339
monitoring : ' datadog://127.0.0.1:8125?batched=false'
332
340
client : ~
333
341
` ` `
334
342
335
- [back to index](index.md)
343
+ [back to index](index.md)
0 commit comments