logstash:wso api manager 日志到弹性

     2023-02-19     39

关键词:

【中文标题】logstash:wso api manager 日志到弹性【英文标题】:logstash: wso api manager logs to elastic 【发布时间】:2022-01-15 20:35:00 【问题描述】:

我的日志如下所示,日志中的每个参数都是静态的。我尝试通过logstash发送弹性并使用Grok模式。但我看不到常规日志。我不擅长 grok。我怎样才能编写合适的 grok 代码? 在输出中我不想看到年份、蒙特信息和空的 GREEDYDATA 部分。

[2021-12-05 20:57:40,513]  INFO - LogCounterMetric Metric Name : apim:response Metric Value: apiName=ApiExp, proxyResponseCode=200, errorType=null, destination=http://1.1.1.1:11/service.asmx, apiCreatorTenantDomain=carbon.super, platform=Other, apiMethod=POST, apiVersion=1.0, gatewayType=SYNAPSE, apiCreator=admin, responseCacheHit=false, backendLatency=229, correlationId=244a4509-52a6-4f37-921d-5d2fc6e40ca3, requestMediationLatency=365, keyType=SANDBOX, apiId=32154b48-70dc5-4cx5-9dgd-7er32e31bacc, applicationName=DefaultApplication, targetResponseCode=200, requestTimestamp=2021-12-05T20:57:39.823Z, applicationOwner=admin, userAgent=Other, eventType=response, apiResourceTemplate=/*, responseLatency=596, regionId=default, responseMediationLatency=2, userIp=1.1.1.1, applicationId=37d453cc-4425-fd31-gf9c-fcdfae89bbd, apiType=SOAP

这是我写的 grok 代码。

\[%TIMESTAMP_ISO8601:timestamp\]%SPACE%LOGLEVEL:level - LogCounterMetric Metric Name : apim:response Metric Value: %GREEDYDATAapiName=%GREEDYDATA:apiName, %GREEDYDATAproxyResponseCode=%GREEDYDATA:proxyResponseCode, %GREEDYDATAerrorType=%GREEDYDATA:errorType, %GREEDYDATAdestination=%GREEDYDATA:destination, %GREEDYDATAapiCreatorTenantDomain=%GREEDYDATA:apiCreatorTenantDomain, %GREEDYDATAplatform=%GREEDYDATA:platform, %GREEDYDATAapiMethod=%GREEDYDATA:apiMethod, %GREEDYDATAapiVersion=%GREEDYDATA:apiVersion, %GREEDYDATAgatewayType=%GREEDYDATA:gatewayType, %GREEDYDATAapiCreator=%GREEDYDATA:apiCreator, %GREEDYDATAresponseCacheHit=%GREEDYDATA:responseCacheHit, %GREEDYDATAbackendLatency=%GREEDYDATA:backendLatency, %GREEDYDATAcorrelationId=%GREEDYDATA:correlationId, %GREEDYDATArequestMediationLatency=%GREEDYDATA:requestMediationLatency, %GREEDYDATAkeyType=%GREEDYDATA:keyType, %GREEDYDATAapiId=%GREEDYDATA:apiId, %GREEDYDATAapplicationName=%GREEDYDATA:applicationName, %GREEDYDATAtargetResponseCode=%GREEDYDATA:targetResponseCode, %GREEDYDATArequestTimestamp=%GREEDYDATA:requestTimestamp, %GREEDYDATAapplicationOwner=%GREEDYDATA:applicationOwner, %GREEDYDATAuserAgent=%GREEDYDATA:userAgent, %GREEDYDATAeventType=%GREEDYDATA:eventType, %GREEDYDATAapiResourceTemplate=%GREEDYDATA:apiResourceTemplate, %GREEDYDATAresponseLatency=%GREEDYDATA:responseLatency, %GREEDYDATAregionId=%GREEDYDATA:regionId, %GREEDYDATAresponseMediationLatency=%GREEDYDATA:responseMediationLatency, %GREEDYDATAuserIp=%GREEDYDATA:userIp, %GREEDYDATAapplicationId=%GREEDYDATA:applicationId, %GREEDYDATAapiType=%GREEDYDATA:apiType

--在 grok 调试器输出中


  "timestamp": [
    [
      "2021-12-05 20:57:40,513"
    ]
  ],
  "YEAR": [
    [
      "2021"
    ]
  ],
  "MONTHNUM": [
    [
      "12"
    ]
  ],
  "MONTHDAY": [
    [
      "05"
    ]
  ],
  "HOUR": [
    [
      "20",
      null
    ]
  ],
  "MINUTE": [
    [
      "57",
      null
    ]
  ],
  "SECOND": [
    [
      "40,513"
    ]
  ],
  "ISO8601_TIMEZONE": [
    [
      null
    ]
  ],
  "SPACE": [
    [
      "  "
    ]
  ],
  "level": [
    [
      "INFO"
    ]
  ],
  "GREEDYDATA": [
    [
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      ""
    ]
  ],
  "apiName": [
    [
      "ApiExp"
    ]
  ],
  "proxyResponseCode": [
    [
      "200"
    ]
  ],
  "errorType": [
    [
      "null"
    ]
  ],
  "destination": [
    [
      "http://1.1.1.1:11/service.asmx"
    ]
  ],
  "apiCreatorTenantDomain": [
    [
      "carbon.super"
    ]
  ],
  "platform": [
    [
      "Other"
    ]
  ],
  "apiMethod": [
    [
      "POST"
    ]
  ],
  "apiVersion": [
    [
      "1.0"
    ]
  ],
  "gatewayType": [
    [
      "SYNAPSE"
    ]
  ],
  "apiCreator": [
    [
      "admin"
    ]
  ],
  "responseCacheHit": [
    [
      "false"
    ]
  ],
  "backendLatency": [
    [
      "229"
    ]
  ],
  "correlationId": [
    [
      "244a4509-52a6-4f37-921d-5d2fc6e40ca3, "
    ]
  ],
  "requestMediationLatency": [
    [
      "365"
    ]
  ],
  "keyType": [
    [
      "SANDBOX"
    ]
  ],
  "apiId": [
    [
      "32154b48-70dc5-4cx5-9dgd-7er32e31bacc"
    ]
  ],
  "applicationName": [
    [
      "DefaultApplication"
    ]
  ],
  "targetResponseCode": [
    [
      "200"
    ]
  ],
  "requestTimestamp": [
    [
      "2021-12-05T20:57:39.823Z"
    ]
  ],
  "applicationOwner": [
    [
      "admin"
    ]
  ],
  "userAgent": [
    [
      "Other"
    ]
  ],
  "eventType": [
    [
      "response"
    ]
  ],
  "apiResourceTemplate": [
    [
      "/*"
    ]
  ],
  "responseLatency": [
    [
      "596"
    ]
  ],
  "regionId": [
    [
      "default"
    ]
  ],
  "responseMediationLatency": [
    [
      "2"
    ]
  ],
  "userIp": [
    [
      "1.1.1.1"
    ]
  ],
  "applicationId": [
    [
      "37d453cc-4425-fd31-gf9c-fcdfae89bbd"
    ]
  ],
  "apiType": [
    [
      "SOAP"
    ]
  ]

【问题讨论】:

尝试删除 [],你的输出看起来不像 JSON 【参考方案1】:

您可以使用 drop filter 的选项 remove_field 删除输出中不需要的特定字段。

更多细节:

https://www.elastic.co/guide/en/logstash/current/plugins-filters-drop.html#plugins-filters-drop-remove_field

【讨论】:

WSO2 API Manager 拒绝设置不安全的标头“Cookie”

】WSO2APIManager拒绝设置不安全的标头“Cookie”【英文标题】:WSO2APIManagerRefusedtosetunsafeheader"Cookie"【发布时间】:2018-01-1707:40:36【问题描述】:我正在使用wso2apimanager(版本2.1.0)来公开一些restapi。我需要将“Cookie”作为标... 查看详情

WSO2 API Manager 使用授权持有者令牌调用现有 API 的问题

】WSO2APIManager使用授权持有者令牌调用现有API的问题【英文标题】:IssuewithWSO2APIManagercallingexistingAPIwithauthorizationbearertoken【发布时间】:2016-06-1720:07:00【问题描述】:我们正在尝试使用APIManager(1.10)调用已使用授权标头令牌的现有... 查看详情

WSO2 Identity Server 和 WSO2 API Manager 集成 - 错误:传输错误 202:绑定失败:地址已在使用中

】WSO2IdentityServer和WSO2APIManager集成-错误:传输错误202:绑定失败:地址已在使用中【英文标题】:WSO2IdentityServerandWSO2APIManagerintegration-ERROR:transporterror202:bindfailed:Addressalreadyinuse【发布时间】:2016-12-2711:42:56【问题描述】:我已经... 查看详情

WSO2 Identity Server 和 WSO2 API Manager 集成 - java.rmi.server.ExportException:端口已在使用:9999;

】WSO2IdentityServer和WSO2APIManager集成-java.rmi.server.ExportException:端口已在使用:9999;【英文标题】:WSO2IdentityServerandWSO2APIManagerintegration-java.rmi.server.ExportException:Portalreadyinuse:9999;【发布时间】:2016-12-2710:07:56【问题描述】 查看详情

是否可以使用 WSO2 API Manager 1.7.0 使用 PIP 点启用细粒度 XACML 授权

】是否可以使用WSO2APIManager1.7.0使用PIP点启用细粒度XACML授权【英文标题】:isitpossibletoEnableFine-GrainedXACMLAuthorizationwithPIPpointsUsingWSO2APIManager1.7.0【发布时间】:2015-02-1217:48:35【问题描述】:其实我已经读过这篇文章:http://wso2.com/li... 查看详情

WSo2 API 管理器

】WSo2API管理器【英文标题】:WSo2APIManager【发布时间】:2016-10-2719:57:48【问题描述】:WSo2APIManager使用哪个内置密钥管理器来管理访问令牌。Ws02身份服务器是否内置在APIManager中。我知道我们可以使用WSo2APIManager配置第三方密钥管... 查看详情

用 WSO2 API 管理器替换 WSO2 身份服务器

】用WSO2API管理器替换WSO2身份服务器【英文标题】:ReplacingWSO2IdentityServerwithWSO2APIManager【发布时间】:2016-07-2305:02:58【问题描述】:我正在使用wso2-apim和wso2-is实现身份验证和授权,因为is和apim之间有一些重复的功能我认为省略is... 查看详情

WSO2 API 管理器和身份服务器集成

】WSO2API管理器和身份服务器集成【英文标题】:WSO2APImanagerandIdentityServerIntegration【发布时间】:2016-11-2910:30:46【问题描述】:我尝试通过以下文档集成wso2IS5.0.0和wso2AM1.7.0。https://docs.wso2.com/display/CLUSTER420/Configuring+the+Identity+Server+... 查看详情

WSO2 API 管理器 (WSO2-AM) 和 Web 服务寻址 (WS-A)

】WSO2API管理器(WSO2-AM)和Web服务寻址(WS-A)【英文标题】:WSO2APIManager(WSO2-AM)andWebservicesaddressing(WS-A)【发布时间】:2016-01-2916:45:01【问题描述】:我有一个托管在使用Web服务寻址(WS-A)的WeblogicServer中的SOAPWeb服务。我正在尝试使用WSO2AP... 查看详情

WSO2 Api 管理器与身份服务器

】WSO2Api管理器与身份服务器【英文标题】:WSO2ApiManagerVsIdeniityServer【发布时间】:2017-03-0716:55:41【问题描述】:谁能澄清一下何时使用APIManager以及何时使用IdentityServer。我看到APIManager带有密钥管理器。这还不够吗。我真的很困... 查看详情

Spring Cloud vs WSO2 API 管理器

】SpringCloudvsWSO2API管理器【英文标题】:SpringCloudvsWSO2APImanager【发布时间】:2016-03-2412:39:03【问题描述】:以构建多个具有容错性和弹性的微服务为目标:目前正在使用SpringBoot构建微服务WSO2APIManager和SpringCloud的主要区别是什么... 查看详情

如何使用 WSO2 API MicroGateway 组合多个微服务

】如何使用WSO2APIMicroGateway组合多个微服务【英文标题】:HowtocomposemultiplemicroserviceswithWSO2APIMicroGateway【发布时间】:2020-03-1521:13:32【问题描述】:新的WSO2APIMicroGateway3.0声明为新功能支持组合多个微服务。我找不到如何做到这一... 查看详情

带有 Analytics 的 WSO2 API 管理器:stats-datasources.xml' - 系统数据源 WSO2AM_STATS_DB 无法更新

】带有Analytics的WSO2API管理器:stats-datasources.xml\\\'-系统数据源WSO2AM_STATS_DB无法更新【英文标题】:WSO2APIManagerwithAnalytics:stats-datasources.xml\'-SystemdatasourceWSO2AM_STATS_DBcannotbeupdated带有Analytics的WSO2API管理器:stats-datasources. 查看详情

配置 WSO2 API 管理器自定义身份验证器和声明

】配置WSO2API管理器自定义身份验证器和声明【英文标题】:configuringWSO2APImanagercustomauthenticatorandclaims【发布时间】:2015-07-2115:38:17【问题描述】:我无法通过使用WSO2API管理器1.9.0的自定义身份验证器来保留自定义声明。对于上下... 查看详情

wso2:如何将一个api的响应用作另一个api的输入参数

...体。我已阅读了很多帖子和博客,但无法继续深入,我在WSO2中相当新。有人可以指导我。谢谢答案您可以通过使用代理服务,调解序列和调解器来实现此目的。您将需要2个执行的序列,登录, 查看详情

使用 WSO2 作为移动应用程序的 API 网关时,如何安全地处理用户密钥和秘密

】使用WSO2作为移动应用程序的API网关时,如何安全地处理用户密钥和秘密【英文标题】:WhenusingWSO2asAPIgatewayformobileapp,howtohandlecomsumer-keyandsecretsecurely【发布时间】:2020-04-1522:33:29【问题描述】:我们正在构建一个移动应用程序... 查看详情

将 WSO2API 管理器从 H2 迁移到 Mysql

】将WSO2API管理器从H2迁移到Mysql【英文标题】:MigrateWSO2APImanagerfromH2toMysql【发布时间】:2014-09-2206:57:29【问题描述】:我有一个正在运行的WSO2API管理器。如何将使用H2内置支持的现有APIManager迁移到MYSQL服务器?我需要执行哪些步... 查看详情

使用 WSO2-AM 处理 JWT

】使用WSO2-AM处理JWT【英文标题】:JWThandlingwithWSO2-AM【发布时间】:2018-06-2714:18:47【问题描述】:我们计划推出API管理解决方案,目前正在使用WSO2AM建立概念验证。我们想使用WSO2API网关来检查是否允许某个消费者应用程序使用API... 查看详情