Created
September 18, 2019 16:39
-
-
Save noahcrowley/4c79db4498ec6dddf6fd6f5eda6a918b to your computer and use it in GitHub Desktop.
Get Discourse Metrics w/Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import requests | |
api_data = { | |
'api_username': 'system', | |
'api_key': os.environ['DISCOURSE_API_KEY'] | |
} | |
r = requests.get("https://community.influxdata.com/admin/dashboard.json", params=api_data) | |
content = r.json() | |
visits = content['global_reports'][0]['total'] | |
users = content['global_reports'][1]['total'] | |
topics = content['global_reports'][3]['total'] | |
posts = content['global_reports'][4]['total'] | |
print("discourse visits=%s,users=%s,topic=%s,posts=%s" % (visits, users, topics, posts), end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment