Skip to content

Instantly share code, notes, and snippets.

@noahcrowley
Created September 18, 2019 16:39
Show Gist options
  • Save noahcrowley/4c79db4498ec6dddf6fd6f5eda6a918b to your computer and use it in GitHub Desktop.
Save noahcrowley/4c79db4498ec6dddf6fd6f5eda6a918b to your computer and use it in GitHub Desktop.
Get Discourse Metrics w/Python
#!/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