skywalking集成nacos动态配置

修改config/application.yml

configuration:
  selector: ${
          
   SW_CONFIGURATION:nacos}
  nacos:
    # Nacos Server Host
    serverAddr: ${
          
   SW_CONFIG_NACOS_SERVER_ADDR:192.168.229.130}
    # Nacos Server Port
    port: ${
          
   SW_CONFIG_NACOS_SERVER_PORT:8848}
    # Nacos Configuration Group
    group: ${
          
   SW_CONFIG_NACOS_SERVER_GROUP:skywalking}
    # Nacos Configuration namespace
    namespace: ${
          
   SW_CONFIG_NACOS_SERVER_NAMESPACE:db20ccfd-db01-47bd-a4d3-393b4e7df260}
    # Unit seconds, sync period. Default fetch every 60 seconds.
    period: ${
          
   SW_CONFIG_NACOS_PERIOD:10}
    # Nacos auth username
    username: ${
          
   SW_CONFIG_NACOS_USERNAME:"nacos"}
    password: ${
          
   SW_CONFIG_NACOS_PASSWORD:"nacos"}

添加nacos配置

比如: dataid = configuration-discovery.default.agentConfigurations group = skywalking 内容:

configurations:
  demo-application:
    agent.trace.ignore_path: "**/actuator/**"

保存以后,在skywalking的控制台会打印如下输出:

Nacos config changed: configuration-discovery.default.agentConfigurations: configurations:
  demo-application:
    agent.trace.ignore_path: "**/actuator/**"

支持的配置项

key Value Description Value Format Example agent-analyzer.default.slowDBAccessThreshold Thresholds of slow Database statement. Overrides agent-analyzer/default/slowDBAccessThreshold of application.yml. default:200,mongodb:50 agent-analyzer.default.uninstrumentedGateways The uninstrumented gateways. Overrides gateways.yml Same as gateways.yml alarm.default.alarm-settings The alarm settings. Overrides alarm-settings.yml Same as alarm-settings.yml core.default.apdexThreshold The apdex threshold settings. Overrides service-apdex-threshold.yml Same as service-apdex-threshold.yml core.default.endpoint-name-grouping The endpoint name grouping setting. Overrides endpoint-name-grouping.yml Same as endpoint-name-grouping.yml core.default.log4j-xml The log4j xml configuration. Overrides log4j2.xml Same as log4j2.xml agent-analyzer.default.traceSamplingPolicy The sampling policy for default and service dimension, override trace-sampling-policy-settings.yml same as trace-sampling-policy-settings.yml configuration-discovery.default.agentConfigurations The ConfigurationDiscovery settings. See configuration-discovery.md

configuration-discovery.default.agentConfigurations

配置内容的格式

configurations:
  //service name
  serviceA:
    // Configurations of service A
    // Key and Value are determined by the agent side.
    // Check the agent setup doc for all available configurations.
    key1: value1
    key2: value2
    ...
  serviceB:

支持的key

Key agent.sample_n_per_3_secs agent.ignore_suffix agent.trace.ignore_path agent.span_limit_per_segment

动态配置的用处

比如:可以动态调整需要ignore的endpoint

经验分享 程序员 微信小程序 职场和发展