-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First custom-metrics-python-SDK asset release #274
Conversation
|
||
# Vars: | ||
# Replace here with your tenancy's root compartment OCID | ||
compartment_ocid = "ocid1.tenancy.oc1....." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this configurable. Config file or parameter.
print(list_availability_domains_response.data) | ||
|
||
# Initialize service client with default config file | ||
monitoring_client = oci.monitoring.MonitoringClient(config,service_endpoint="https://telemetry-ingestion.eu-frankfurt-1.oraclecloud.com") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this configurable.
# Posting custom metrics to oci monitoring for each of the metrics (max, used, available) | ||
|
||
# Max limit | ||
post_metric_data_response = monitoring_client.post_metric_data( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is a duplicate (essentially six times) with a single change (name). Create a function for that and provide the change only. Much easier to read and maintain.
...tom-metric-python-SDK-services-limit-monitoring/files/Scripts/postServiceLimitsMetricsIAM.py
Show resolved
Hide resolved
|
||
# Vars: | ||
# Replace here with your tenancy's root compartment OCID | ||
compartment_ocid = "ocid1.tenancy.oc1....." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this customizable.
|
||
# Initialize service client with default config file | ||
#monitoring_client = oci.monitoring.MonitoringClient(config={}, signer=signer) | ||
monitoring_client = oci.monitoring.MonitoringClient(config={},service_endpoint="https://telemetry-ingestion.eu-frankfurt-1.oraclecloud.com",signer=signer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that generic or should it be customizable?
print ("Service: ", s_name, "Limit: ", l_name, "Scope: ", l_scope) | ||
|
||
# If the resource limit has an AD scope, we have to specify the AD or we'll get an API 400 response | ||
if l_scope == "AD" : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as for postServiceLimitsMetricsIAM.py apply here. Do some factoring to reduce the code duplication and potential oversights.
Hi folks!,
I'm just publishing the "Using python SDK to create OCI Monitoring custom metric namespace: Services Limit monitoring example use case" initial release with the IAM user principal python script.
I want to test the process for code review @oheimburger. Once I've survived to the falcon eye ;-), I'll publish a secondary script with using Instance Principals with a secondary review of the contents.
@NicolaCimitile, have a look to the structure and let me know your thoughts.
Thanks a lot in advance to both.
Rgds.
Pablo