Micrometer gauge not appearing on prometheus endpoint - gauge

I have instrumented my code inside a method for micrometer gauge like this:
SimpleMeterRegistry registry = new SimpleMeterRegistry();
Gauge
.builder("greeting_service_gauge", new AtomicInteger(new Random().nextInt(10)), AtomicInteger::get)
.register(registry);
I have added few other metrics too.
Other metrics appear on prometheus endpoint, but this gauge metrics doesn't.
What am I missing here?

You are registering the gauge to the SimpleMeterRegistry. Instead you should be registering the metric to the Prometheus registry (or the CompositeMeterRegistry)
You can inject the MeterRegistry if this is a Spring project. Or use the global Metrics.globalRegistry to get the composite one.
Gauge
.builder("greeting_service_gauge", new AtomicInteger(new Random().nextInt(10)), AtomicInteger::get)
.register(Metrics.globalRegistry);

Related

Cannot apply path pattern for firestore in EventArc

I was trying to use EventArc to monitor Firestore changes, which will trigger a Cloud Run service.
It works by listening to Any Resource or specific resource name.
Resource name
projects/PROJECT_Id/databases/(default)
It works, but it will listen to all changes in firestore. However, I want to filter the event to a specific collection. I have tried a few combinations to the pattern, and none of them works. E.g.
projects/PROJECT_Id/databases/(default)/users/*
projects/PROJECT_Id/databases/(default)/users/{user}
Any ideas? Thanks :)
I have seen in the image you shared, under the “Resource” section you selected “specific resource” instead can you try to change it to a “path pattern” and you will be able to write a specific path that the trigger object needs to respect.
You can refer to this documentation for Applying a path pattern when filtering in Eventarc.
You can also check out the AuditLog step of Trigger Cloud Run with events from Eventarc codelab for an example on how to use path patterns.

HTTPCode_Target_5XX_Count for Application/ELB does not exist by default

We are trying to set up dashboards using AWS/ApplicationELB metrics, specifically HTTPCode_Target_5XX_Count. However, this metric has never been created and I cannot see it in CloudWatch metrics list either. I guess it's because the service we're building has never had 500 errors in the past.
This does not look like a normal behaviour. According to the documentation, the reporting criteria for this metric is report if there is non-zero value. However, I was expecting HTTPCode_Target_5XX_Count metric to be created without any 500, since it's a default CloudWatch metric.
Am I missing something here? Should we artificially cause 500 errors on our service so that this metric gets created?

"Android Device Verification" Service quota usage

I'm using Android Device Verification service (SafetyNet's attestation api), for verifying whether the request is sent from the same app which I built.
We have a quota limit of 10,000 (which can be increased) on the number of request we can do using SafetyNet's attestation api.
Now, I want to know if my limit is breached so that I can stop using that API.
For that I was looking into stack-driver alerting but I couldn't find Android Device Verification service in it. (Even though I was able to find it in Quotas)
You can monitor Safetynet Attestations in Stackdriver by specifying these filters and settings:
Resource Type: Consumed API
Metric: Request count (type search term "serviceruntime.googleapis.com/api/request_count" to find correct count quickly)
Add Filter service = androidcheck.googleapis.com
Use aggregator "sum" to get the total count of requests.
You can set advanced aggregation options to aggregate the daily level to compare with your quota. This can be done by setting Aligner: "sum" and Alignment period: "1440m". This gives daily sums of requests for the chart (1440m=24h*60m = number of minutes per day).

How to separate metrics per endpoint using compojure

I have enabled metrics on Compojure using metrics-clojure-ring
(def app
(->
(wrap-defaults myapp api-defaults)
(expose-metrics-as-json)
(instrument)
))
but the metrics come out for all api's combined. is there a way to instrument per endpoint?
What exactly do you mean with instrumenting per endpoint? The metrics are combined on the /metrics endpoint for every endpoint. The underlying library (Coda Hale metrics) does that for you.
If you only want one metric on an endpoint you can select one key from the all-metrics hash map. E.g., create a route for /metrics/<metric-name> and only select the metric-name key from all-metrics and return that. If you really want to only track one metric instead of all at once, I think you have to fork the Coda Hale code and change the implementation.
Let me know if this helps. I might not have understood your question.

Grafana - Configure Custom Metrics from Cloudwatch

I am new to Grafana. I am setting it up to view data from Cloudwatch for a Custom Metrics. Custom Metrics Namespace Name is JVMStats, Metric is JVMHeapUsed, Dimension is instance Id. If I configure these data, I am not able to get the graph. Can you please advice me on how to get the data?
Regards
Karthik
I want to do the same.
As far as I can tell, it's not possible out of the box with the latest Grafana (2.6 at time of writing). See this issue.
This pull request implements it. It's currently tagged as 3.0-beta1. So I expect we'll both be able to do what we want come version 3.0.
EDIT: inserting proof of 3.0-beta-1 working
I installed 3.0-beta-1, and was able to use Custom Metrics, as evidenced by this image:
I managed to add my custom metrics now, only issue I had was that I listed my custom metrics in the "Data Source" configurations with commmas and spaces:
Custom1, Custom2
but it must be only commas:
Custom1,Custom2
And it works for me. The preview in the text box shows this, but I missed it.
Another option is to configure AWS CloudWatch job to collect data into Axibase Time Series Database where CustomMetrics namespace is enabled out-of-the-box:
Disclosure: I work for Axibase.