Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,330 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm using the Azure Monitor Metrics SDK in my Java application to query metrics for redis resource. However, I'm encountering a com.fasterxml.jackson.databind.exc.MismatchedInputException with the error message "Missing required creator property 'timespan' (index 0)". How could I fix this?
This is my code snippet:
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-redis</artifactId>
<version>2.39.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.12.1</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-monitor-query</artifactId>
<version>1.3.2</version>
</dependency>
final MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder() .credential(clientSecretCredential) .buildClient()
final MetricsQueryResult metricsQueryResult = metricsQueryClient.queryResource(instanceId,Arrays.asList("usedmemory"));
The full stacktrace is :
Exception in thread "main" com.azure.core.exception.HttpResponseException: Deserialization Failed.
at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.decodeByteArray(HttpResponseBodyDecoder.java:99)
at com.azure.core.implementation.serializer.HttpResponseDecoder$HttpDecodedResponse.getDecodedBody(HttpResponseDecoder.java:93)
at com.azure.core.implementation.http.rest.SyncRestProxy.handleBodyReturnType(SyncRestProxy.java:192)
at com.azure.core.implementation.http.rest.SyncRestProxy.handleRestResponseReturnType(SyncRestProxy.java:148)
at com.azure.core.implementation.http.rest.SyncRestProxy.handleRestReturnType(SyncRestProxy.java:220)
at com.azure.core.implementation.http.rest.SyncRestProxy.invoke(SyncRestProxy.java:86)
at com.azure.core.implementation.http.rest.RestProxyBase.invoke(RestProxyBase.java:125)
at com.azure.core.http.rest.RestProxy.invoke(RestProxy.java:97)
at com.sun.proxy.$Proxy3.listSync(Unknown Source)
at com.azure.monitor.query.implementation.metrics.MetricsImpl.listWithResponse(MetricsImpl.java:1038)
at com.azure.monitor.query.MetricsQueryClient.queryResourceWithResponse(MetricsQueryClient.java:158)
at com.azure.monitor.query.MetricsQueryClient.queryResource(MetricsQueryClient.java:122)
at com.test.global.service.azure.AzureRedisService.queryMetrics(AzureRedisService.java:137)
at com.test.global.service.azure.AzureRedisService.main(AzureRedisService.java:52)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Missing required creator property 'timespan' (index 0)
at [Source: (byte[])"{"value":[]}"; line: 1, column: 12] (through reference chain: com.azure.monitor.query.implementation.metrics.models.MetricsResponse["timespan"])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1755)
at com.fasterxml.jackson.databind.deser.impl.PropertyValueBuffer._findMissing(PropertyValueBuffer.java:192)
at com.fasterxml.jackson.databind.deser.impl.PropertyValueBuffer.getParameters(PropertyValueBuffer.java:158)
at com.fasterxml.jackson.databind.deser.ValueInstantiator.createFromObjectWith(ValueInstantiator.java:288)
at com.fasterxml.jackson.databind.deser.impl.PropertyBasedCreator.build(PropertyBasedCreator.java:202)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:518)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1405)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:351)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:184)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4674)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3723)
at com.azure.core.implementation.jackson.ObjectMapperShim.readValue(ObjectMapperShim.java:240)
at com.azure.core.util.serializer.JacksonAdapter.lambda$deserialize$9(JacksonAdapter.java:359)
at com.azure.core.util.serializer.JacksonAdapter.useAccessHelper(JacksonAdapter.java:491)
at com.azure.core.util.serializer.JacksonAdapter.deserialize(JacksonAdapter.java:347)
at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.deserialize(HttpResponseBodyDecoder.java:176)
at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.deserializeBody(HttpResponseBodyDecoder.java:150)
at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.decodeByteArray(HttpResponseBodyDecoder.java:93)
... 13 more
After adding these permissions to my azure app, this problem gone:
Microsoft.Insights/Metrics/read, Microsoft.Insights/MetricDefinitions/read