当前位置: 首页 > article >正文

Skywalking python agent安装配置

一、安装Python Agent
pip install apache-skywalking

二、配置并启动Agent
系统起始位置添加如下代码:
from skywalking import agent, config
#配置SkyWalking
config.init(agent_collector_backend_services=‘192.168.100.201:11800’, agent_instance_name=‘XZFLottery’)

#启动SkyWalking Agent
agent.start()

三、如果报错,检查变量名称
/usr/local/lib/python3.8/site-packages/skywalking/agent.py

def init(**kwargs) -> None:
“”"
Used to initialize the configuration of the SkyWalking Python Agent.
Refer to the official online documentation
https://skywalking.apache.org/docs/skywalking-python/next/en/setup/configuration/
for more information on the configuration options.

Args:
    **kwargs: Any of the configuration options listed
"""
glob = globals()

print(kwargs.items())

for key, val in kwargs.items():

    print(key)
    print(val)
    print(options)

    if key not in options:
        raise KeyError(f'Invalid configuration option {key}')

    glob[key] = val

四、官网
Legacy Setup
You can always fall back to our traditional way of integration as introduced below, which is by importing SkyWalking into your project and starting the agent.

Defaults
By default, SkyWalking Python agent uses gRPC protocol to report data to SkyWalking backend, in SkyWalking backend, the port of gRPC protocol is 11800, and the port of HTTP protocol is 12800,

See all default configuration values in the Configuration Vocabulary

You could configure agent_collector_backend_services (or environment variable SW_AGENT_COLLECTOR_BACKEND_SERVICES) and set agent_protocol (or environment variable SW_AGENT_PROTOCOL to one of gprc, http or kafka according to the protocol you would like to use.

Report data via gRPC protocol (Default)
For example, if you want to use gRPC protocol to report data, configure agent_collector_backend_services (or environment variable SW_AGENT_COLLECTOR_BACKEND_SERVICES) to :11800, such as 127.0.0.1:11800:

from skywalking import agent, config

config.init(agent_collector_backend_services=‘127.0.0.1:11800’, agent_name=‘your awesome service’, agent_instance_name=‘your-instance-name or ’)

agent.start()
Report data via HTTP protocol
However, if you want to use HTTP protocol to report data, configure agent_collector_backend_services (or environment variable SW_AGENT_COLLECTOR_BACKEND_SERVICES) to :12800, such as 127.0.0.1:12800, further set agent_protocol (or environment variable SW_AGENT_PROTOCOL to http):

Remember you should install skywalking-python with extra requires http, pip install "apache-skywalking[http].

from skywalking import agent, config

config.init(agent_collector_backend_services=‘127.0.0.1:12800’, agent_name=‘your awesome service’, agent_protocol=‘http’, agent_instance_name=‘your-instance-name or ’)

agent.start()
Report data via Kafka protocol
Please make sure OAP is consuming the same Kafka topic as your agent produces to, kafka_namespace must match OAP side configuration plugin.kafka.namespace

Finally, if you want to use Kafka protocol to report data, configure kafka_bootstrap_servers (or environment variable SW_KAFKA_BOOTSTRAP_SERVERS) to kafka-brokers, such as 127.0.0.1:9200, further set agent_protocol (or environment variable SW_AGENT_PROTOCOL to kafka):

Remember you should install skywalking-python with extra requires kafka, pip install “apache-skywalking[kafka]”.

from skywalking import agent, config

config.init(kafka_bootstrap_servers=‘127.0.0.1:9200’, agent_name=‘your awesome service’, agent_protocol=‘kafka’, agent_instance_name=‘your-instance-name or ’)

agent.start()
Alternatively, you can also pass the configurations via environment variables (such as SW_AGENT_NAME, SW_AGENT_COLLECTOR_BACKEND_SERVICES, etc.) so that you don’t need to call config.init.

All supported environment variables can be found in the Environment Variables List.


http://www.kler.cn/a/512970.html

相关文章:

  • (10)深入浅出智能合约OpenZeppelin开源框架
  • STM32低功耗模式
  • 第14篇:从入门到精通:掌握python上下文管理器
  • 【Linux】Linux入门(三)权限
  • MongoDB vs Redis:相似与区别
  • 国内汽车法规政策标准解读:GB 44495-2024《汽车整车信息安全技术要求》
  • 【源码+文档+调试讲解】基于Spring Boot的协作会话平台
  • C++0到1面试点(二)
  • web-view环境下,H5页面打开其他小程序
  • Linux 如何使用parted进行磁盘分区?
  • HTML<img>标签
  • Qt Network编程之HTTP请求与处理
  • AI 之网:网络诈骗者的 “高科技伪装术”—— 智能诈骗的神秘面纱
  • jenkins-视图管理
  • TDengine 做 Apache SuperSet 数据源
  • 工业制造离不开的BOM
  • 为AI聊天工具添加一个知识系统 之57 前端工具:知识图谱、语义网络和认知地图 之2
  • 产品溯源管理系统(源码+文档+部署+讲解)
  • Docker Compose的使用
  • 9种提高 GitHub 国内访问速度的方案_hub
  • Spring Boot Actuator 详细介绍
  • Vue 3 自定义 Hook:实现页面数据刷新与滚动位置还原
  • 【2024年华为OD机试】(A卷,100分)- 匿名信 (Java JS PythonC/C++)
  • 【python】基于决策树,SVM 和 神经网络 预测银行客户流失
  • 认识 Milvus 向量数据库
  • Linux Bash 中使用重定向运算符的 5 种方法