This script will download cluster data and metrics from Ops Manager via APIs.
To run you need Python 3.x. You also need the requests library. You can install this via the command line when you have Python installed:
$ pip3 install requests
- Open Ops Manager or Atlas in your browser and login. Make sure that the user you're logging in with has read access to all orgs and projects that you want to obtain the data of.
- Get the value of the Ops Manager or Atlas authentication cookie. For Atlas,
the cookie is called
mmsa-hosted
, and for Ops Manager it'smmsa-hosted
. E.g.7135ba929465c2e36bc129e8c01efef4-20230131
. You can view cookies in your browser's Developer Console or via the i icon next to the URL in Chrome. - Ops Manager only: Note the base URL (host) of Ops Manager in your browser.
This is everything that comes before the first '/',
e.g.
https://acme-corp.com:8080
- Run the following command in the folder that contains the
getdata.py
script. Note that the BASEURL can be ommited when querying Atlas:
$ python3 getdata.py AUTHCOOKIE -u BASEURL
If successful, it will save a CSV file clusters.csv
containing the cluster
data, and a bunch of JSON files in subfolders containing the metrics.
If you get any 403 errors, check if you are using the correct BASEURL or AUTHCOOKIE.
cluster_id | replica_set_id | name | host_id | replica_state | cpu | ram_mb | wt_cache_size_gb | version |
---|---|---|---|---|---|---|---|---|
63d... | TestRS | TestRS_7 | cee... | PRIMARY | 2 | 3816 | 0.25 | 4.2.23 |
63d... | TestRS | TestRS_8 | 08d... | SECONDARY | 2 | 3816 | 0.25 | 4.2.23 |
63d... | TestRS | TestRS_9 | 6bd... | SECONDARY | 2 | 3816 | 0.25 | 4.2.23 |
For sample output of the metrics, please see the sample-metrics.json file.