- This topic has 3 replies, 2 voices, and was last updated 2 weeks, 6 days ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Home › Forums › FABRIC General Questions and Discussion › Regarding measuring CPU load, RAM utilization and other metrics in a slice
Tagged: MFLib
Hi all,
I get it that the masurement of metrics in a slice is done using the MFlib library. What I am unable to understand and to locate in the Fabric examples directory is how to get those values as strings or numbers inside variables. I would be highly obliged if someone could guide me in the right direction. Thank you!
There is a REST API that can be used to access the metrics programmatically in addition to the Grafana views. I will have to add the documentation for that. I’ll post back here once that is done.
Thank you so much. That would really be kind of you.
Here are the instructions for getting metric data programmatically using curl.
Create a jupyter notebook with the following cells.
# Import MFLib Class
from mflib.mflib import MFLib
slice_name = “<your slice name>”
mf = MFLib(slice_name)
# Get the ht_user & ht_password for the slice’s meas_node.
data = {}
# Set the info you want to get.
data[“get”] = [“ht_user”, “ht_password”]
# Call info using data
info_results = mf.info(“prometheus”, data)
print(info_results)
Alternatively you can just add the second cell above to the existing prometheus_grafana.ipynb notebook.
Create a tunnel thru the bastion host for port 9090. This is similar to the tunnel needed for accessing grafana but using port 9090:localhost:9090 instead of 10010:localhost:443.
The above cell should print out the meas_node_ip as “Found meas node as meas-node at <your meas_node_ip>”
ssh -L 9090:localhost:9090 -F ssh_config -i slice_key ubuntu@<your meas_node ip>
Then make API call using curl or python requests etc…
Here is a simple example using the ht_user and ht_password retrieved above to get the latest up metrics.
curl -k -u <ht_user>:<ht_password> https://localhost:9090/api/v1/query\?query\=up