通过http_listener_v2将python输出(json输出)发送到telegraf

2024-06-11 04:29:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图通过http_listener_v2将测试_数据从下面的python脚本(abc.py)输出到telegraf

abc.py
------
import requests
url = "https://testazure.local/telegraf"
test_data = {'key1': 'value1'}

op = requests.post(url, data = test_data)
print(op.test_data)

下面是我的telegraf.conf文件的输入片段

telegraf.conf
-----------------
[[inputs.http_listener_v2]]
#   ## Address and port to host HTTP listener on
# methods = ["POST", "PUT"]
   data_format = "json"

不确定,如果我正在将所有requsite详细信息传递给输入插件

试图执行python脚本时出现连接错误。如有任何建议/帮助,将不胜感激

Traceback (most recent call last):
  File "abc.py", line 6, in <module>
    x = requests.post(url, data = test_data)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)

requests.exceptions.ConnectionError: HTTPSConnectionPool(host'testazure.local', port=443): 
Max retries exceeded with url: /telegraf (Caused by 
NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f9eb8c72438>: 
Failed to establish a new connection: [Errno 111] Connection refused',))

Tags: pytest脚本jsonhttpurldatalocal