Metric Counter showing as zero in dashboard See im...
# general
n
Metric Counter showing as zero in dashboard See image of metric in console exporter. When i try to display on panel it shows up as zero(see attached) What do i have to do to get the metric to display as the counter value?
s
The raw counter value can't be shown. You either use the rate of change or the total change in the window. What are you trying to achieve?
n
thanks for reply@Srikanth Chekuri, I am trying to display the metric value in a graph e.g. at 9pm I imported(ran an application) and the value was 777 for the counter, I imported again and the value was 666. I want to be able to see what the metric was for each import. Am i using the wrong metric type or something?
example
s
Can you help me understand what the metric is measuring?
n
@Srikanth Chekuri we import a file periodically and we want to show a metric for the number of records in the file e.g. File at 9am 777 records File at 11am 750 records etc
s
You could use the gauge metric type and record the value. How often do you import files?
n
if varies, some applications do regularly(every hour) and others 1 per week. Are you saying to use this metric type? - https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter.createobservablegauge?view=net-8.0
s
Yes, if you want to use metrics for the task. but with that frequency, I'd go as far as to suggest recording it as the log and doing aggregations based on the log records instead.
n
@Srikanth Chekuri thanks So i have created an ObservableGauge and i can see the value now(see image). Me code is below. How do I filter by tags e.g. bin.provider in my case?
Copy code
Meter.CreateObservableGauge(
	"bins.infiletest",
	() => value,
	"int",
	"bins in file",
	new List<KeyValuePair<string, object>> { new("bin.provider", BINProvider) });
s
The bin provider should appear in filter just like the service_name
n
That's what I thought, it does not appear and when I add it I get no result
s
The auto suggestions should show the attribute. If you just type
bin
what options show up?
n
im not getting an options for bin. Its like the tags are not there?
s
Yes, I see the type being an object. I don't think it's valid. The value for tag values are primitive types such as string, number etc.. but not an object
What is the value of
BINProvider
? Is it a string? I think that's where the issue is.
n
yes it is a string, is there an issue with it being a string?
s
See how service_name is working but not the bin provider. I don't think it is a string otherwise it would show up fine in tags.
n
I changed the value to an int just to see but no difference. I am using .net and the list of tags is KeyValuePair where the key is a string. So the tag is a string. Do you know where I could look in clickhouse to verify data is present?
Copy code
public static void AddBINSInFileGauge(int BINProviderId, int value)
{
	Meter.CreateObservableGauge(
		"bins.infiletest",
		() => value,
		"int",
		"bins in file",
		new List<KeyValuePair<string, object>> { new("bin.providerid", BINProviderId) });
}
s
In the n/w tab you should see /autocomplete api calls. If they are not returning anything then it is high likely that it doesn't exist in the first place. Do you see all tags when you use console/stdout exporter https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Exporter.Console/README.md.
n
@Srikanth Chekuri thanks for reply. Changed to use the following overload function
public ObservableGauge<T> CreateObservableGauge<T>(string name, Func<IEnumerable<Measurement<T>>> observeValues, string? unit = null, string? description = null) where T : struct =>
new ObservableGauge<T>(this, name, observeValues, unit, description, tags: null);
Example usage:
public static void AddBINFileGauge(string BINProviderName, int value) => Meter.CreateObservableGauge(
"ccs.bin.file",
() => new List<Measurement<long>>()
{
new(value, KeyValuePair.Create<string, object>("ccs.bin.providername", BINProviderName)),
});
And the tags are now showing up. So for whatever reason previous function seems to ignore tags even though I had then set
s
Glad to hear that it's working now.