【问题标题】:azure webhook to stream splunk data用于流式传输 splunk 数据的 azure webhook
【发布时间】:2021-10-04 15:21:32
【问题描述】:
我想将 splunk 报告安排到 azure web-hook 并将其保存到 Cosmos DB 中。(在处理之后)This tutorial 让我了解了如何通过 azure 函数处理数据并将数据保存到 cosmos db 中(在爪哇)。为了解决难题的下一部分,我正在寻求一些关于如何进行的建议:
-
如何在 Azure 上设置和托管 webhook ?
我应该在 EventHubOutput 函数内设置一个 HttpTrigger 并将其部署到函数应用程序中吗?或者我应该使用 Azure 事件网格中的 Webhook 吗?(不清楚如何执行此操作)。我不希望流式传输任何大量数据,并且希望保持较低的消耗成本。那么,我应该走哪条路呢?任何指向教程的指针都会在这里有所帮助。
-
如何处理@EventHubOutput (referring the java example in the tutorial) 上的 webhook 数据处理?我需要在这里做什么设置和配置?任何工作示例都会有所帮助。
【问题讨论】:
标签:
azure
azure-functions
azure-web-app-service
【解决方案1】:
我最终只使用@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();
}
}