OCI Application Performance Monitoring (APM) is a service that provides deep visibility into the performance of applications and enables DevOps professionals to diagnose issues quickly in order to deliver a consistent level of service.
To use Oracle APM, we need to have the APM server’s endpoint. To get the endpoint, you should copy your own APM_BASE_URL and APM_PUB_KEY from OCI web console and set them as environment variables.
(A screenshot of a typical APM Domains UI)
APM_BASE_URL is the DataUploadEndpoint in APMDomains page; APM_PUB_KEY is the public key named auto_generated_public_datakey in the same page. You can just click the word show to copy them.
Warning
The values below are fake and for demo purposes only. You should replace them with your own APM_BASE_URL and APM_PUB_KEY.
“The public key and public channel supposed to be used by something like a browser in which any end user may see the key. For server side instrumentation you should use the private data key. Changing this will make no difference in any way. The idea is that you may want/need to change the public key more often.”
–Avi Huber
You can also set it in your python code programmatically with os.environ like what we have done in previous chapter.
There are two ways to use OCI APM in HiQ. The legacy way is to use HiQOciApmContext which uses py_zipkin under the hood. The modern way is to use HiQOpenTelemetryContext, which uses the new OpenTelemetry api.
OCI APM doesn’t support Protobuf metrics data for now. Only Json format data via HTTP is supported. So OtmExporterType.ZIPKIN_JSON is required in line 10 above.
Run the driver code and go to the OCI APM web console, we can see:
Click hiq_service:__main, we can see the trace details:
The Oracle Telemetry (T2) system provides REST APIs to help with gathering metrics, creating alarms, and sending notifications to monitor services built on the OCI platform. HiQ integrates with T2 seamlessly.
The OCI(Oracle Cloud Infrastructure) Streaming service provides a fully managed, scalable, and durable solution for ingesting and consuming high-volume data streams in real-time. Streaming is compatible with most Kafka APIs, allowing you to use applications written for Kafka to send messages to and receive messages from the Streaming service without having to rewrite your code. HiQ integrates with OCI streaming seamlessly.
To use OCI streaming you need to install oci python package first:
pipinstalloci
Then set up OCI streaming service and create a stream called hiq for instance. Please refer to OCI Streaming Document for how to set them up.
The target code is the same as before, and the following is the sample driver code:
Due to the high latency of Kafka message sending, we process the metrics in the unit of HiQ tree in another process Jack. What you need to do is to set the environment variables JACK and HIQ_OCI_STREAMING to 1 like line 20 and 21, and also the streaming endpoint(OCI_STM_END) and streaming OCID(OCI_STM_OCID) with the information from your OCI web console.
Run the driver code and then go to OCI web console, you can see the HiQ trees have been recorded.
Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud, now a CNCF (Cloud Native Computing Foundation) project used by many companies and organizations. Prometheus collects and stores its metrics as time series data, i.e. metrics information is stored with the timestamp at which it was recorded, alongside optional key-value pairs called labels. If the targe code/service is a long running service, Prometheus is a good option for monitoring solution. HiQ provide an out-of-the-box solution for Prometheus.
Like the other integration methods, you need to set environment variable TRACE_TYPE. To enable prometheus monitoring, you need to set it to prometheus.
Up to your performance SLA, you can call start_http_server from the main thread or, for better performance, you may want to use pushgateway but that involves more setup and operation overhead.
The following example shows how to expose Prometheus metrics with HiQ.
Run the driver code and visit http://localhost:8681/metrics, and we can see the metrics has been exposed. Please be noted that the metrics name has an hiq_ as the prefix so that the metrics name is unique.
We can see the summary of main, func1, func2 exposed. If the prometheus server is running in the same host, you can add the config in prometheus.yml to scrape the metrics for user to query.