我正在使用Extended metrics检索某些VMS的某些指标。每个查询似乎都花费很长时间,因为表中每15秒为每个VM创建新记录。
因此,我尝试在最近5分钟内查询该表,但该表不起作用,并给我一个错误。有人知道如何查询这些WADMETRICS表吗?
我的代码。
CloudStorageAccount account = CloudStorageAccount.parse(connectionString);
CloudTableClient cloudTableClient = account.createCloudTableClient();
DateTime fiveMinutesAgo = DateTime.now().minusMinutes(5);
String queryString = TableQuery.generateFilterCondition("Timestamp", TableQuery.QueryComparisons.GREATER_THAN_OR_EQUAL, fiveMinutesAgo.toString());
TableQuery<TableServiceEntity> query = TableQuery.from(TableServiceEntity.class).where(queryString);
CloudTable table = cloudTableClient.getTableReference("WADMetricsPT1MP10DV2S20191017");
System.out.println(table.exists());
System.out.println(table.getName());
for (TableServiceEntity entity : table.execute(query)) {
System.out.println(entity.getPartitionKey() + "\t" + entity.getRowKey());
}
运行此命令后我会得到什么。
枚举结果时发生错误,请检查原始异常以获取详细信息。 java.util.NoSuchElementException:枚举结果时发生错误,请检查原始异常以获取详细信息。 在com.microsoft.azure.storage.core.LazySegmentedIterator.hasNext(LazySegmentedIterator.java:113) 在com.optum.oea.workbench.service.RemoteAzureService.getVmMetric(RemoteAzureService.java:138) 在com.optum.oea.workbench.service.RemoteAzureService.getVmMetric(RemoteAzureService.java:120) 在com.optum.oea.workbench.controller.MetricsController.getMetric(MetricsController.java:75) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498) 在org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) 在org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) 在org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892) 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) 在org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039) 在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) 在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) 在org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:634) 在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:741) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在com.optum.oea.workbench.config.WorkbenchAttestationFilter.doFilterInternal(WorkbenchAttestationFilter.java:33) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:320) 在org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) 在org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在com.optum.oea.workbench.config.AuthenticationFilter.doFilter(AuthenticationFilter.java:65) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:100) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)处 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334) 在org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) 在org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) 在org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) 在org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114) 在org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) 在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) 在org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) 在org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 在org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:853) 在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1587) 在org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624) 在org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(Thread.java:748) 引起原因:com.microsoft.azure.storage.table.TableServiceException:错误的请求 在com.microsoft.azure.storage.table.TableServiceException.generateTableServiceException(TableServiceException.java:52) 在com.microsoft.azure.storage.table.CloudTableClient $ 2.preProcessResponse(CloudTableClient.java:415) 在com.microsoft.azure.storage.table.CloudTableClient $ 2.preProcessResponse(CloudTableClient.java:390) 在com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:138) 在com.microsoft.azure.storage.core.LazySegmentedIterator.hasNext(LazySegmentedIterator.java:109)
答案 0 :(得分:1)
根据我的测试,如果您想通过过滤时间戳来查询the WADMETRICS tables,请参考以下代码:
CloudStorageAccount account = CloudStorageAccount.parse("connection string");
CloudTableClient client = account.createCloudTableClient();
CloudTable table = client.getTableReference("WADMetricsPT1MP10DV2S20191017");
System.out.println(table.exists());
System.out.println(table.getName());
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
cal.add(Calendar.HOUR, -19);
cal.add(Calendar.MINUTE,-21);
Date date = cal.getTime();
// SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
// date = df.parse(df.format(date));
//
System.out.println(date.toString());
String queryString = TableQuery.generateFilterCondition("Timestamp",TableQuery.QueryComparisons.GREATER_THAN_OR_EQUAL, date);
TableQuery<TableServiceEntity> query = TableQuery.from(TableServiceEntity.class).where(queryString);
Iterable<TableServiceEntity> results = table.execute(query);
int i=0;
for (TableServiceEntity entity:results
) {
i +=1;
System.out.println(entity.getPartitionKey());
}
System.out.println(i);