Logstash API 配置http

Logstash API configuration http

我正在尝试在 Logstash 中创建一个 API 连接并将数据推送到 elasticsearch。 Elasticsearch 和 Logstash 版本都是 7.1.0。 下面是 logstash 文件的 id:

input {
          http_poller {
            urls => {
              test2 => {
                method => get
        user => "readonly"
            password => "mypass@123"
                url => "https://nfr.saas.appdynamics.com/controller/rest/applications?output=JSON
                headers => {
                  Accept => "application/json"
                }
             }
            }
            request_timeout => 60
            # Supports "cron", "every", "at" and "in" schedules by rufus scheduler
            schedule => { cron => "* * * * * UTC"}
            codec => "json"
            # A hash of request metadata info (timing, response headers, etc.) will be sent here
            metadata_target => "http_poller_metadata"
          }
        }

        output {
          elasticsearch { hosts => ["localhost:9200"] }
          stdout { codec => rubydebug }
        }

我收到一个错误:

An unexpected error occurred! {:error=>java.nio.file.AccessDeniedException: D:\logstash-7.1.0\logsta
        sh-7.1.0\data\.lock, :backtrace=>["sun.nio.fs.WindowsException.translateToIOExce
        ption(sun/nio/fs/WindowsException.java:83)", "sun.nio.fs.WindowsException.rethro
        wAsIOException(sun/nio/fs/WindowsException.java:97)", "sun.nio.fs.WindowsException

编辑 1:post 授予对 @apt-get_install_skill 建议的数据文件夹的权限,下面是我收到的超时错误:

    [0] "_http_request_failure"
    ],
    "http_request_failure" => {
                "request" => {
             "method" => "get",
                "url" => "https://nfr.saas.appdynamics.com/controller/rest/applications?output=JSON",
            "headers" => {
                "Accept" => "application/json"
            },
               "auth" => {
                 "user" => "readonly",
                 "pass" => "mypass@123",
                "eager" => true
            }
        },
        "runtime_seconds" => 10.004,
                   "name" => "test2",
                  "error" => "connect timed out",
              "backtrace" => nil
    }
}

我是 API 的新手,我不确定如何简单地从 URL 获取输出。你能帮我纠正这个问题吗? URL 当我在我的浏览器上点击它时工作。

问题不在于 elasticsearch 输出,而在于文件的权限

D:\logstash-7.1.0\logstash-7.1.0\data\.lock

如堆栈跟踪中所述:

error=>java.nio.file.AccessDeniedException: D:\logstash-7.1.0\logstash-7.1.0\data\.lock, :backtrace =>[[sun.nio.fs.WindowsException.translateToIOExce 选项(sun/nio/fs/WindowsException.java:83)", "sun.nio.fs.WindowsException.rethro wAsIOException(sun/nio/fs/WindowsException.java:97)", "sun.nio.fs.WindowsException

您需要确保执行logstash的用户有读写该文件的权限