-
-
Notifications
You must be signed in to change notification settings - Fork 7
Grafana: track blacklisted domains count
fab edited this page Aug 29, 2023
·
1 revision
To track the total count of blacklisted entries across time using Grafana, you'll need to do the following:
- Make sure you have InfluxDB set up as a data source in Grafana.
- Modify the script to record counts rather than individual entries.
- Set up a Grafana dashboard to visualize the data.
- Open Grafana and go to the configuration (gear icon) on the left panel.
- Click on "Data Sources" and then "Add data source".
- Choose "InfluxDB" from the list.
- Fill in the details for your InfluxDB instance, including the URL, authentication token, and organization.
- Click "Save & Test".
To record the number of blacklisted entries every hour, modify the send_to_influxdb
function in the script:
def send_to_influxdb(domains_count):
client = InfluxDBClient(url=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG)
write_api = client.write_api(write_options=SYNCHRONOUS)
point = Point("blacklist_stats").field("count", domains_count)
write_api.write(INFLUXDB_BUCKET, INFLUXDB_ORG, point)
And update the if __name__ == '__main__':
block:
if __name__ == '__main__':
domains = fetch_blacklisted_domains()
send_to_influxdb(len(domains))
- In Grafana, click on the "+" icon on the left panel and choose "Dashboard".
- Click "Add New Panel".
- Choose the InfluxDB data source you added earlier.
- In the query editor:
- From: "blacklist_stats".
- Select: field(value) -> "count".
- Click on "Apply".
- Under the "Visualization" tab, you can choose how you want to display the data. A graph or bar gauge would be appropriate for visualizing the count across time.
- You can also adjust the time range (for example, Last 7 days) and the refresh interval (every 1 hour) to fit your needs.
- Save the dashboard.
Now, every hour, as your script sends the count of blacklisted domains to InfluxDB, Grafana will visualize the changes, giving you an overview of how the blacklist count evolves over time.