Azure Function App集成Application Insights:Metrics与Custom Dimensions缺失问题求助
Azure Function App集成Application Insights:Metrics与Custom Dimensions缺失问题求助
大家好,我在配置Azure Function App将日志和指标同步到Application Insights时遇到了问题,目前只能看到基础的追踪信息,但自定义维度和自定义指标都没有正常出现在Application Insights中,想请各位帮忙排查下问题所在。
我使用的代码如下:
import azure.functions as func import datetime import logging import requests from settings import settings from services.exchangerate_service import ExchangeRateService from azure.identity import DefaultAzureCredential from azure.monitor.opentelemetry import configure_azure_monitor from opentelemetry import metrics credential = DefaultAzureCredential() configure_azure_monitor( connection_string="InstrumentationKey=xx-xx-xx-xx-xx;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=xx-xx-xx-xx-xx", credential=credential ) logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) app = func.FunctionApp() @app.timer_trigger(schedule=settings.IBAN_CRON, arg_name="myTimer", run_on_startup=True, use_monitor=False) def timer_trigger(myTimer: func.TimerRequest) -> None: if myTimer.past_due: logging.info('The timer is past du3e!') logger.info("Segato5", extra={"custom_dimension": "Kam_value","test1": "val1"}) meter = metrics.get_meter_provider().get_meter(__name__) counter = meter.create_counter("segato2") counter.add(8)
目前的问题现象:
- 我能在Application Insights的Traces中看到基础日志内容,但日志里通过
extra参数传入的custom_dimension、test1等自定义维度字段完全没有显示 - 我用OpenTelemetry创建的自定义计数器指标
segato2,也没有出现在Application Insights的Metrics模块中,完全搜索不到这个指标
(补充说明:原本的截图显示,Traces列表里只有纯日志文本,没有可展开查看自定义维度的入口;Metrics Explorer中也找不到我定义的segato2指标条目)
备注:内容来源于stack exchange,提问作者Thomas Segato
相关产品推荐
相关产品推荐

