With Cisco FSO Platform, metrics might be reported straight from the code. Unlike utilizing any form of auto-instrumentation function, that is helpful when a service proprietor is aware of what must be reported. A typical use case could be enabling reporting of area particular metrics – like variety of gadgets within the catalogue for e-shops, variety of unfinished orders, SQL queries to particular desk, and so on. Basically, something which is likely to be attention-grabbing to watch for some time frame, or in contrast amongst totally different implementation variations.
Hands-on steerage on the best way to set this up
Open Telemetry has a beneficial means of how the metric reporting needs to be routed to any software program. The service which will probably be reporting the info goes to ship them to the open telemetry collector, which is a fairly handy common receiver, processor and exported of (not solely) open telemetry formatted information. Open Telemetry collector will then be configured to relay all the info to the FSO Platform tenant.
The very first thing that it’s essential to safe is a FSO Platform tenant, to which the info will circulation. I occur to have one prepared, however I have to get the principal and clientId and clientSecret used to export information. After logging in, I opened a “Configuration” tab, then chosen “Kubernetes and APM,” named my configuration, and adopted the data introduced to me:
That needs to be all I have to configure my Open Telemetry collector.
Open Telemetric Collector configuration
Next, I used Docker picture otel/opentelemetry-collector-contrib:newest, since that’s the only means for me to run the collector. All I have to do is to supply the best configuration, which is finished by supplying –config parameter.
After some brief analysis, I made a decision to make use of the next configuration:
Then the one factor left to do is to begin the collector:
% docker run --rm -t -v $PWD/otel-config.yaml:/and so on/otel-collector-config.yaml -p 4317:4317 otel/opentelemetry-collector-contrib:newest --config=/and so on/otel-collector-config.yaml
The collector begins actually rapidly, I solely verified that every one the extensions I added are initialised, no errors printed out.
My go-to language is Java, so lets strive that first. Open Telemetry offers a fairly in depth listing of SDK libraries for any fashionable languages and runtimes. The Java SDK appears to be essentially the most mature one on that listing. This doesn’t imply that Java is the one selection. Realistically, there’s already help for reporting Open Telemetry information from any actively used language. And if not, there’s at all times an choice to report information utilizing totally different receivers. For instance, you need to use Prometheus or Zipkin help which your programming or runtime setting already has.
Metric Data Source
Since I don’t have any utility prepared for this experiment, I selected to do the guide instrumentation (it can almost definitely be extra enjoyable anyway).
After organising a undertaking and a dependency on the newest SDK model obtainable (1.29.0), I put collectively the next class package deal com.cisco.fso:
Let’s undergo some necessary components of this code snippet.
First one is the Resource declaration. In Open Telemetry, each information level must be reported within the context of a useful resource, together with metrics. Here I’m declaring my useful resource as one thing with the attributes service.identify and service.occasion.id — which is a de-facto normal, described as a part of the Open Telemetry semantic conventions.
If you discover that area extra, you’ll discover plenty of different conventions, defining which useful resource attributes needs to be reported for varied elements, like container, pod, service operating deployed on some cloud supplier and plenty of extra. By utilizing service.identify and service.occasion.id, we’re reporting a service. On FSO Platform that is mapped to the sort apm:service_instance.
Another half value mentioning is the metric initialization. You can see that I named my metric “my.first.metric”, set the sort to gauge, declared that it is going to be reporting lengthy values, and registered a callback, which does return random lengthy values. Not very helpful, however needs to be ok to get some information in.
After executing this system, you will notice new logs reported by the Open Telemetry Collector we began earlier than:
Exploring ingested metrics utilizing FSO Platform
This is an effective signal that the info arrived from my Java program to the collector. Also, the collector comprises additional logs which counsel that it was in a position to report the info to the platform. So, let’s get again to the browser and take a look at whether or not we will see reported information.
Apparently my service was registered by the platform, however there will not be a lot information reported. And, any metrics that are displayed by default, will not be populated. Why is that occuring?
All the metrics that are there are derived from spans and traces which might be reported by any normal APM Service and even any framework which you’d be utilizing. The Open Telemetry SDK has good auto-discoverable options for Spring, Micronaut, and different instruments you is likely to be utilizing. After placing some load to your service, you’d see these. But that’s not what we need to do at this time. We need to see our crucial “my.first.metric” information factors.
For that, we might want to use Query Builder, a System Application of FSO Platform, which lets you question saved information straight utilizing Unified Query Language.
FETCH metrics(dynamicmetrics:my.first.metric) FROM entities(apm:service_instance)[attributes(service.name)='manualService']
This specific question fetches the reported metric for the apm:service_instance, which was mapped from the useful resource reported utilizing the Java snippet above. It retrieves values of a metric my.first.metric and reveals them on the output. The dynamicmetrics string represents a particular namespace for metrics, which had been ingested however will not be outlined in any of the options which the present tenant is at the moment subscribed to.
Obviously, that is solely the start and most of you wouldn’t be solely reporting customized metrics by hand, you’d be instrumenting code of your present purposes, infrastructure, cloud suppliers and something you’ll be able to mannequin.
Ready to strive? Get acknowledged with Cisco FSO Platform
Related sources
Share: