@@ -9,19 +9,19 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
99
1010# Monitoring.
1111
12- Enqueue provides a tool for monitoring message queues.
12+ Enqueue provides a tool for monitoring message queues.
1313With 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.
1515The tool could be integrated with virtually any analytics and monitoring platform.
16- There are several integration:
16+ There are several integration:
1717 * [ Datadog StatsD] ( https://datadoghq.com )
1818 * [ 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/ )
2020We are working on a JS\WAMP based real-time UI tool, for more information please
[ contact us
] ( [email protected] ) .
2121
2222![ Grafana Monitoring] ( images/grafana_monitoring.jpg )
2323
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.
2525
2626* [ Installation] ( #installation )
2727* [ 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
4040composer req enqueue/monitoring:0.9.x-dev
4141```
4242
43- ## Track sent messages
43+ ## Track sent messages
4444
4545``` php
4646<?php
@@ -50,7 +50,7 @@ use Enqueue\Monitoring\GenericStatsStorageFactory;
5050$statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1:8086?db=foo');
5151$statsStorage->pushSentMessageStats(new SentMessageStats(
5252 (int) (microtime(true) * 1000), // timestamp
53- 'queue_name', // queue
53+ 'queue_name', // queue
5454 'aMessageId',
5555 'aCorrelationId',
5656 [], // headers
@@ -76,7 +76,7 @@ $context->createProducer()->send($queue, $message);
7676$statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1:8086?db=foo');
7777$statsStorage->pushSentMessageStats(new SentMessageStats(
7878 (int) (microtime(true) * 1000),
79- $queue->getQueueName(),
79+ $queue->getQueueName(),
8080 $message->getMessageId(),
8181 $message->getCorrelationId(),
8282 $message->getHeaders()[],
@@ -99,7 +99,7 @@ $statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1
9999$statsStorage->pushConsumedMessageStats(new ConsumedMessageStats(
100100 'consumerId',
101101 (int) (microtime(true) * 1000), // now
102- $receivedAt,
102+ $receivedAt,
103103 'aQueue',
104104 'aMessageId',
105105 'aCorrelationId',
@@ -127,16 +127,16 @@ $consumer = $context->createConsumer($queue);
127127$consumerId = uniqid('consumer-id', true); // we suggest using UUID here
128128if ($message = $consumer->receiveNoWait()) {
129129 $receivedAt = (int) (microtime(true) * 1000);
130-
130+
131131 // heavy processing here.
132-
132+
133133 $consumer->acknowledge($message);
134-
134+
135135 $statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1:8086?db=foo');
136136 $statsStorage->pushConsumedMessageStats(new ConsumedMessageStats(
137137 $consumerId,
138138 (int) (microtime(true) * 1000), // now
139- $receivedAt,
139+ $receivedAt,
140140 $queue->getQueueName(),
141141 $message->getMessageId(),
142142 $message->getCorrelationId(),
@@ -151,7 +151,7 @@ if ($message = $consumer->receiveNoWait()) {
151151## Track consumer metrics
152152
153153Consumers 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.
155155Call this code from time to time between processing messages.
156156
157157``` php
@@ -165,13 +165,13 @@ $statsStorage = (new GenericStatsStorageFactory())->create('influxdb://127.0.0.1
165165$statsStorage->pushConsumerStats(new ConsumerStats(
166166 'consumerId',
167167 (int) (microtime(true) * 1000), // now
168- $startedAt,
168+ $startedAt,
169169 null, // finished at
170- true, // is started?
170+ true, // is started?
171171 false, // is finished?
172172 false, // is failed
173173 ['foo'], // consume from queues
174- 123, // received messages
174+ 123, // received messages
175175 120, // acknowledged messages
176176 1, // rejected messages
177177 1, // requeued messages
@@ -182,7 +182,7 @@ $statsStorage->pushConsumerStats(new ConsumerStats(
182182
183183## Consumption extension
184184
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 ) .
186186It could collect consumed messages and consumer stats for you.
187187
188188``` php
@@ -236,8 +236,16 @@ There are available options:
236236* 'measurementSentMessages' => 'sent-messages',
237237* 'measurementConsumedMessages' => 'consumed-messages',
238238* 'measurementConsumers' => 'consumers',
239+ * 'client' => null,
240+ * 'retentionPolicy' => null,
239241```
240242
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+
241249## Datadog storage
242250
243251Install additional packages:
@@ -256,7 +264,7 @@ $statsStorage = (new GenericStatsStorageFactory())->create('datadog://127.0.0.1:
256264For best experience please adjust units and types in metric summary.
257265
258266Example dashboard:
259-
267+
260268![ Datadog monitoring] ( images/datadog_monitoring.png )
261269
262270
@@ -311,7 +319,7 @@ There are available options:
311319
312320## Symfony App
313321
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.
315323
316324``` yaml
317325# config/packages/enqueue.yaml
@@ -325,11 +333,11 @@ enqueue:
325333 transport : ' amqp://guest:guest@foo:5672/%2f'
326334 monitoring : ' wamp://127.0.0.1:9090?topic=stats'
327335 client : ~
328-
336+
329337 datadog :
330338 transport : ' amqp://guest:guest@foo:5672/%2f'
331339 monitoring : ' datadog://127.0.0.1:8125?batched=false'
332340 client : ~
333341` ` `
334342
335- [back to index](index.md)
343+ [back to index](index.md)
0 commit comments