【问题标题】:New Relic create alert based on custom eventsNew Relic 基于自定义事件创建警报
【发布时间】:2020-08-28 14:58:17
【问题描述】:

我们使用他们的 API https://docs.newrelic.com/docs/insights/event-data-sources/custom-events/apm-report-custom-events 向 New Relic 报告自定义事件。

如果在特定时间范围内这些自定义事件的数量超过 X,有没有办法创建警报。

SELECT count(*) FROM `event_name` WHERE `field` = 'OFAC' SINCE 30 minutes ago

我收到一条错误消息:Invalid clauses in alert conditions: SINCE

注意event_namefield 被替换为字符串。

【问题讨论】:

    标签: newrelic


    【解决方案1】:

    使用 nrql 警报?

    获取您的 nrql 查询,然后删除从 30 分钟开始

    SELECT 函数(属性) 从事件 WHERE 属性 [比较] [AND|OR ...]

    例如

    nrql_query = "FROM K8sVolumeSample SELECT latest(fsUsedPercent) FACET podName, 
    volumeName, pvcName WHERE clusterName IN ('cluster-prod') "
    

    https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/alert-conditions/create-nrql-alert-conditions

    我们通过 terraform 使用它们。 文档给出了一个很好的例子https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/nrql_alert_condition

    您用于仪表板的查询可用于警报。对于仪表板 SELECT count(*) FROM event_name WHERE field = 'OFAC' TIMESERIES SINCE 30 分钟前或类似的东西

    例如,对于一个计数示例 - 获取唯一 k8 对象的计数

    SELECT uniqueCount(K8sNodeSample.entityId) AS 'Nodes', 
    uniqueCount(K8sNamespaceSample.clusterName) AS 'Clusters', 
    uniqueCount(K8sNamespaceSample.entityId) AS 'Namespaces', 
    uniqueCount(K8sDeploymentSample.entityId) AS 'Deployments', 
    uniqueCount(K8sPodSample.entityId) AS 'Pods', 
    uniqueCount(K8sContainerSample.containerID) AS 'Containers' FROM 
    K8sNodeSample, K8sNamespaceSample, K8sDeploymentSample, K8sPodSample, 
    K8sContainerSample  WHERE clusterName IN ('cluster-prod')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多