用于流式传输 splunk 数据的 azure webhook

azure webhook to stream splunk data

我想将 splunk 报告安排到 azure web-hook 并将其保存到 Cosmos DB 中。(处理后)This tutorial 让我了解了如何通过天蓝色函数(在 java 中)。为了解决难题的下一部分,我正在寻求一些关于如何着手的建议:

  1. 如何在 Azure 上设置和托管 Webhook? 我应该在 EventHubOutput 函数中设置一个 HttpTrigger 并将其部署到函数应用程序中吗?或者我应该使用 Azure 事件网格中的 Webhook 吗?(不清楚如何执行此操作)。我不打算流式传输任何大量数据,而是希望保持较低的消耗成本。那么,我应该走哪条路呢?任何指向教程的指针都会在这里有所帮助。

  2. 如何处理 @EventHubOutput ( referring the java example in the tutorial) 上的 webhook 数据处理?。我需要在这里做什么设置和配置?任何工作示例都会有所帮助。

我最终只使用 @HttpTrigger 并使用 @CosmosDBOutput 绑定输出以保留数据。类似这样,想知道有没有更好的办法。

public class Function {

@FunctionName("PostData")
public HttpResponseMessage run(
        @HttpTrigger(
                name = "req",
                methods = {HttpMethod.GET, HttpMethod.POST},
                authLevel = AuthorizationLevel.ANONYMOUS)
                HttpRequestMessage<Optional<String>> request,

        @CosmosDBOutput( name = "databaseOutput", databaseName = "SplunkDataSource",
                         collectionName = "loginData", 
                         connectionStringSetting = "CosmosDBConnectionString")
                         OutputBinding<String> document,
                         final ExecutionContext context) { 
          context.getLogger().info("Java HTTP trigger processed a request.");

    // Parse the payload
    String data = request.getBody().get();

    if (data == null) {
        return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body(
          "Please pass a name on the query string or in the request body").build();
    } else {
        // Write the data to the Cosmos document.
        document.setValue(data);
        context.getLogger().info("Persisting payload to db :" + data);
        return request.createResponseBuilder(HttpStatus.OK).body(data).build();
    }
}