Configuration
Basic Configuration
The streaming API uses Kafka to transfer metrics from Paragon Active Assurance. You therefore need to do the following to get the streaming API up and running:
-
Add the following to
/etc/netrounds/netrounds.conf
:KAFKA_METRICS_ENABLED = True
-
In
/etc/netrounds/metrics.yaml
setstreaming-api: true
-
Run
sudo systemctl stop kafka
-
In
/etc/kafka/server.properties
replacelocalhost:9092
with0.0.0.0:9092
for the listeners and addadvertised.listeners=PLAINTEXT://ip_or_url:9092
Here,
ip_or_url
should be set to the address that the clients will use. It is important thatip_or_url
is routable; setting0.0.0.0
as for the listeners results in an error.Note: Kafka is non-trivial to configure. If you change other aspects of the Kafka configuration, make sure you know what you are doing. Refer to the Apache Kafka documentation.Then run
sudo systemctl start kafka
-
Enable the metrics and TimescaleDB services (skip the latter if you are not using TimescaleDB):
sudo systemctl enable netrounds-timescaledb sudo systemctl enable netrounds-metrics sudo systemctl start netrounds-timescaledb netrounds-metrics
-
Finally, restart the services:
sudo systemctl restart netrounds* apache2
Security Recommendations: Restricting Access to the Kafka Instance
At present, there is no authorization built into the streaming API. However, you can restrict access to the API by configuring your firewall. Here is how to set up persistent iptables rules for allowing and disallowing access to Kafka:
Install the iptables-persistent
package:
sudo apt-get install iptables-persistent
In order to permanently add rules for IPv4, open the file /etc/iptables/rules.v4
and insert rules similar to the following:
*nat :PREROUTING ACCEPT [1:52] :INPUT ACCEPT [1:52] -A INPUT -p tcp --dport 9092 -s IP_ADDRESS -j ACCEPT -A INPUT -p tcp --dport 9092 -j DROP :OUTPUT ACCEPT [1:60] :POSTROUTING ACCEPT [1:60] COMMIT
Here, we allow access to the Kafka port (9092) for a specific IP address, while blocking all other connections to that port.
Similarly, in order to add IPv6 rules, edit the file /etc/iptables/rules.v6
according to the code below:
*filter :INPUT ACCEPT [5856:1295124] -A INPUT -p tcp --dport 9092 -s IPv6_ADDRESS -j ACCEPT -A INPUT -p tcp --dport 9092 -j DROP :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [74127:5871992] -A INPUT -p tcp -m tcp --dport 42595 -j ACCEPT COMMIT
Important: Reboot the machine.
Next, check if the instructions are applied by running the command
sudo iptables -L -v -n