Tuesday, December 5, 2023

Reporting Customized Metrics to FSO Platform The use of the OpenTelemetry SDK


With Cisco FSO Platform, metrics will also be reported immediately from the code. In contrast to the usage of any roughly auto-instrumentation function, this comes in handy when a carrier proprietor is aware of what must be reported. A normal use case can be enabling reporting of area particular metrics – like choice of pieces within the catalogue for e-shops, choice of unfinished orders, SQL queries to precise desk, and so forth. Mainly, the rest which may well be fascinating to watch for some time frame, or in comparison amongst other implementation variations.

Arms-on steerage on learn how to set this up

Open Telemetry has a really useful method of the way the metric reporting must be routed to any tool. The carrier which will likely be reporting the knowledge goes to ship them to the open telemetry collector, which is a fairly handy common receiver, processor and exported of (no longer best) open telemetry formatted information. Open Telemetry collector will then be configured to relay all of the information to the FSO Platform tenant.

The very first thing that you wish to have to protected is a FSO Platform tenant, to which the knowledge will drift. I occur to have one in a position, however I wish to get the primary and clientId and clientSecret used to export information. After logging in, I opened a “Configuration” tab, then decided on “Kubernetes and APM,” named my configuration, and adopted the ideas offered to me:

FSO Platform - Getting Agent Principal
FSO Platform – Getting Agent Primary

That are supposed to be all I wish to configure my Open Telemetry collector.

Open Telemetric Collector configuration

Subsequent, I used Docker symbol otel/opentelemetry-collector-contrib:newest, since that’s the most simple method for me to run the collector. All I wish to do is to give you the proper configuration, which is completed through supplying –config parameter.

After some brief analysis, I made up our minds to make use of the next configuration:

OTEL Collector configuration
Click on symbol to get right of entry to the gist in Github

Then the one factor left to do is to start out the collector:

% docker run --rm -t -v $PWD/otel-config.yaml:/and so forth/otel-collector-config.yaml 

-p 4317:4317 otel/opentelemetry-collector-contrib:newest --config=/and so forth/otel-collector-config.yaml

The collector begins actually briefly, I best verified that all of the extensions I added are initialised, no mistakes published out.

My go-to language is Java, so we could check out that first. Open Telemetry supplies a fairly in depth listing of SDK libraries for any trendy languages and runtimes. The Java SDK appears to be probably the most mature one on that listing. This doesn’t imply that Java is the one selection. Realistically, there may be already reinforce for reporting Open Telemetry information from any actively used language. And if no longer, there may be all the time an method to record information the usage of other receivers. As an example, you’ll be able to use Prometheus or Zipkin reinforce which your programming or runtime atmosphere already has.

Metric Information Supply

Since I don’t have any software in a position for this experiment, I selected to do the guide instrumentation (it’s going to possibly be extra amusing anyway).

After putting in a undertaking and a dependency on the most recent SDK model to be had (1.29.0), I put in combination the next elegance bundle com.cisco.fso:

Java Class reporting OTEL Metric
Click on symbol to get right of entry to the gist in Github

Let’s undergo some necessary portions of this code snippet.

First one is the Useful resource declaration. In Open Telemetry, each information level must be reported within the context of a useful resource, together with metrics. Right here I’m mentioning my useful resource as one thing with the attributes carrier.title and carrier.example.identification — which is a de-facto usual, described as a part of the Open Telemetry semantic conventions.

In the event you discover that house extra, you’ll in finding numerous different conventions, defining which useful resource attributes must be reported for quite a lot of elements, like container, pod, carrier operating deployed on some cloud supplier and lots of extra. By means of the usage of carrier.title and carrier.example.identification, we’re reporting a carrier. On FSO Platform that is mapped to the sort apm:service_instance.

Some other section value citing is the metric initialization. You’ll see that I named my metric “my.first.metric”, set the sort to gauge, declared that it’s going to be reporting lengthy values, and registered a callback, which does go back random lengthy values. Now not very helpful, however must be just right sufficient to get some information in.

After executing this system, you’ll see new logs reported through the Open Telemetry Collector we began earlier than:

OTEL Collector log
Click on symbol to get right of entry to the gist in Github

Exploring ingested metrics the usage of FSO Platform

This can be a just right signal that the knowledge arrived from my Java program to the collector. Additionally, the collector accommodates additional logs which recommend that it used to be in a position to record the knowledge to the platform. So, let’s get again to the browser and try whether or not we will be able to see reported information.

FSO Platform Entity Centric Service view
FSO Platform – Cloud Local Software Observability – Carrier Entity view

It seems that my carrier used to be registered through the platform, however there don’t seem to be a lot information reported. And, any metrics which can be displayed through default, don’t seem to be populated. Why is that taking place?

The entire metrics which can be there are derived from spans and lines which might be reported through any usual APM Carrier or even any framework which you’d be the usage of. The Open Telemetry SDK has great auto-discoverable options for Spring, Micronaut, and different gear you may well be the usage of. After striking some load for your carrier, you possibly can see the ones. However that’s no longer what we wish to do lately. We wish to see our crucial “my.first.metric” information issues.

For that, we will be able to wish to use Question Builder, a Gadget Software of FSO Platform, which lets you question saved information immediately the usage of Unified Question Language.

FETCH metrics(dynamicmetrics:my.first.metric)
FROM entities(apm:service_instance)[attributes(service.name)='manualService']

This actual question fetches the reported metric for the apm:service_instance, which used to be mapped from the useful resource reported the usage of the Java snippet above. It retrieves values of a metric my.first.metric and presentations them at the output. The dynamicmetrics string represents a unique namespace for metrics, that have been ingested however don’t seem to be outlined in any of the answers which the present tenant is recently subscribed to.

FSO Platform - Query Builder
FSO Platform – Question Builder

Clearly, that is best the start and maximum of you wouldn’t be best reporting customized metrics through hand, you’d be instrumenting code of your current packages, infrastructure, cloud suppliers and the rest you’ll be able to fashion.

In a position to take a look at? Get mentioned with Cisco FSO Platform 

Similar sources



Please enter your comment!
Please enter your name here

Related Stories