【问题标题】:Dealing with missing metrices in calculations处理计算中缺失的指标
【发布时间】:2018-01-15 17:01:33
【问题描述】:

我使用一个公式来计算大约。 MySQL 实例的最大内存消耗(简化并用 PromQL 编写)读取: p>

(
    mysql_global_variables_key_buffer_size +
    mysql_global_variables_query_cache_size +
    mysql_global_variables_tmp_table_size +
    mysql_global_variables_innodb_buffer_pool_size +
    mysql_global_variables_innodb_additional_mem_pool_size +
    mysql_global_variables_innodb_log_buffer_size +
    (
        mysql_global_variables_max_connections *
        (
            mysql_global_variables_sort_buffer_size +
            mysql_global_variables_read_buffer_size +
            mysql_global_variables_read_rnd_buffer_size +
            mysql_global_variables_join_buffer_size +
            mysql_global_variables_thread_stack +
            mysql_global_variables_binlog_cache_size
        )
    )
)

不幸的是,mysql_global_variables_innodb_additional_mem_pool_size 指标并非总是存在于每个实例中,如果将其包含在计算中,则会导致“无数据”。

absent(v instant-vector) 函数可以用来解决这个问题,但我不知道如何解决。

我希望 不存在 度量被替换为常量(在这种情况下为0)。有可能吗?

您能否提供一些关于如何处理 PromQL 中的计算缺失指标的提示?

【问题讨论】:

    标签: prometheus promql


    【解决方案1】:
    mysql_global_variables_innodb_additional_mem_pool_size or up * 0
    

    https://www.robustperception.io/existential-issues-with-metrics/ 更详细地研究了这个问题。

    【讨论】:

    • 这是绝妙的把戏(也是很棒的博文)!谢谢,布赖恩。解决了。​​
    【解决方案2】:

    如果我们尝试对两个可能缺失的指标求和,则接受的解决方案将无法正常工作。 在我的具体情况下,它是mysql_info_schema_innodb_metrics_transaction_trx_rseg_history_len(来自mariadb)和mysql_global_status_innodb_history_list_length(来自mysql)。 提供的解决方案为我提供了单个主机的 3 个图表。

    我使用了以下解决方法:

    (metric1{hostname="h"} or on() vector(0))+(metric2{hostname="h"} or on() vector(0))
    

    取自这里:https://github.com/grafana/grafana/issues/2393#issuecomment-192522042

    【讨论】:

      猜你喜欢
      • 2011-11-18
      • 2019-01-19
      • 2020-10-19
      • 2020-02-09
      • 2013-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多