One of the advantages of messaging is that the new behavior that wasn't initially envisioned can easily be grafted to a system because of its lowly coupled nature. In our case, the fact that all application logs are not being published to a single topic exchange allows us to create a specific consumer that will receive only error messages and report them to the operations team.
If you remember our discussion about the routing keys used by the application logs' publishers, all we need to do is to receive messages whose routing first component (that is, the string before the first period of the routing key) indicates an error. These components are as follows:
For the syslog publisher:
err
,crit
,alert,
andemerg
for the Log4j publisher:
ERROR
andFATAL
Now we know this, we can create a Python script that will create and bind a queue to the app-logs
topic exchange, using the one-binding-per-error-message-routing-key pattern. The following code shows the logs-error-reporter...