首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用REST配置syslog通知

使用REST配置syslog通知
EN

Stack Overflow用户
提问于 2022-02-15 20:02:37
回答 1查看 110关注 0票数 0

如何使用API配置深度安全/工作负载安全系统日志设置?

根据0/api-reference/tag/System-Settings#operation/modifySystemSettings下面的代码

代码语言:javascript
复制
value = deepsecurity.SettingValue('1')
system_settings = deepsecurity.SystemSettings(platform_setting_syslog_config_id=value) 
api_response = api_instance.modify_system_settings(system_settings, 'v1')

提供了修改platformSettingSyslogConfigId更改syslog服务器配置配置文件的能力,但是如何添加配置实际的syslog服务器IP、端口、协议(UDP/TCP)、syslog工具和格式(CEF/LEEF)?

我希望我的python脚本将syslog配置为指向特定主机,只使用API,即不打开Web控制台,运行rsyAdd.1-d。

EN

回答 1

Stack Overflow用户

发布于 2022-02-24 21:14:18

我相信您正在寻找的答案是在API文档的创建Syslog配置部分。

到目前为止,这个方法还没有出现在Python中,因此必须手动调用。

下面这样的东西--它使用了requests Python模块--可能对您有用:

代码语言:javascript
复制
import requests

# define credentials
API_KEY = "<YOUR_API_KEY>"
MANAGER_ADDRESS = "<C1WS_OR_DS_ENDPOINT>"

# init required headers
headers = {
    # for Cloud One Workload Security
    "Authorization": f"ApiKey {API_KEY}",
    # for DS:
    "api-secret-key": API_KEY,

    "api-version": "v1",
    "Content-Type": "application/json",
}

# define syslog configuration
payload = {
    # main options
    "name": "<YOUR_SYSLOG_NAME>",
    "description": "<YOUR_SYSLOG_DESCRIPTION>",
    "hostName": "<YOUR_SYSLOG_ENDPOINT>",
    "port": 514,
    "transport": "tcp|udp",
    "facility": "kernel|user|mail|daemon|authorization|syslog|printer|news|uucp|clock|authpriv|ftp|ntp|log-audit|log-alert|cron|local0|local1|local2|local3|local4|local5|local6|local7",
    "eventFormat": "standard|cef|leef",

    # additional options
    "agentDirectForwarding": True | False,
    "includeTimezone": True | False,
    "privateKey": "<string>",
    "certificateChain": ["<string>"],
    "sourceIdentifier": "<string>",
}

# make post request to manager
response = requests.request(
    method="POST",
    url=MANAGER_ADDRESS,
    headers=headers,
    data=payload,
    # for DS:
    verify=False,
)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71132677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档