Skip to content
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

Merged
merged 6 commits into from
Aug 2, 2023

Conversation

paalonso
Copy link
Collaborator

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


# Vars:
# Replace here with your tenancy's root compartment OCID
compartment_ocid = "ocid1.tenancy.oc1....."
Copy link
Member

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")
Copy link
Member

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(
Copy link
Member

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.


# Vars:
# Replace here with your tenancy's root compartment OCID
compartment_ocid = "ocid1.tenancy.oc1....."
Copy link
Member

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)
Copy link
Member

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" :
Copy link
Member

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.

@paalonso paalonso removed the request for review from NicolaCimitile August 2, 2023 11:31
@oheimburger oheimburger merged commit 754254b into main Aug 2, 2023
@oheimburger oheimburger deleted the paalonso-custom-metric-script1 branch August 2, 2023 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants