From nobody Thu May 12 20:40:49 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8688B1AC9FFE; Thu, 12 May 2022 20:40:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KzkFF2K5Kz4hqR; Thu, 12 May 2022 20:40:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652388049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=z/BiLhFA2r8QO62jvIVM5oBKb6q4TBpvRAKqqre8u0A=; b=YMlQSevTpMI7Rs26nydGXW6vERzjyI7gwxfEtx1NjJJUghWSZwhGsuo3Di9d6zSXrEgiJw USFVjXXnj55C3U2P/LYsF+qde0Xbv7VuxNqj8W98oW2IuWzMnze7ip0ef2L1tqoW5xnHNp +aQwRxqtVCK7fG1+RzwSnDo/mE+lvQz11yvuBZ5prfZwlz3stbuopUVyuNZ/mv/6CbqWnq jDlUqmpPalyfBpzlBbCCHJEAbdZhL6PGwLAOlRjIKZP4xzPgLrHIqVqGc4TBROoK5uFvtG BbbM6BpL8kuM/gBiADTFl9sOvUk/U4i3AgP+nmLAH5SZcaUsmrIlejjL9wcdMg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C241154A2; Thu, 12 May 2022 20:40:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24CKeniZ042894; Thu, 12 May 2022 20:40:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24CKenx0042893; Thu, 12 May 2022 20:40:49 GMT (envelope-from git) Date: Thu, 12 May 2022 20:40:49 GMT Message-Id: <202205122040.24CKenx0042893@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: e4f508d5a211 - stable/13 - prometheus_sysctl_exporter: fix metric aliasing List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e4f508d5a211e99dd6179794b51fefa329886be3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652388049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=z/BiLhFA2r8QO62jvIVM5oBKb6q4TBpvRAKqqre8u0A=; b=MjbyASC6D4W01yWTjBdQTy/9egH4JZmqk8uIdJQSforv7Ss/VIruMjnl2RsqGfrf5m34Lv zUa4Jfh9ZJQRoyvKu4clxBNLKFidzxPhl8FURkNqeTnsCLGf27RD5+zRysQOTsdE8DY/Mu sXa0BSflOfQenaXSmzXT+bOGYWXnBU+FsFMu4/L/tCS46FJYr+vQzc+VQFPbKJUixBo5Ed ltJR4pE2bib94dRVOX4V8NScUSPM/2gDCNCiFtiuCJ2shwUFqPKpcPX+VSE+519wxuup+4 lJEC8bHxBG8ejNZQQDcnWI+42A17JielGJqPTJnqave03j8mVejmnSnPwLU31g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652388049; a=rsa-sha256; cv=none; b=ZWmJo2XRlKwl7SY2ZRNHjmi+w9EpaaHQl8Gc8Kiyh8U1Yzq44XHE0wFYMaNgu3OuMPdJzO zg2ArJm8T+tXLF078ePu4Maj2AG0ysUhYExcFDUCDW5vWYt6qm4cSQIp/nMCxK2d25LbVD 3Nz5SNaM+mJpxPVFCQK6rIbHJ6QSZ1Xd09V+yFCP4o5rt1I2jl2WAqyvBWpS8Gxha1O2nc 6dQyoab+fxWr9mgczNE4+xJV2yJwkj2HqqwqCQPVKJiDJgUa7ODFrJ/YvAlP1iAaYZC6qa AhpvJL9w4gBniyBfdBtjPYIpSU1iRaPfQY1bLYLQHBHia/PSxm/1VXncIbc76A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=e4f508d5a211e99dd6179794b51fefa329886be3 commit e4f508d5a211e99dd6179794b51fefa329886be3 Author: Alan Somers AuthorDate: 2022-04-18 21:29:37 +0000 Commit: Alan Somers CommitDate: 2022-05-12 20:40:05 +0000 prometheus_sysctl_exporter: fix metric aliasing When exporting sysctls to Prometheus, the exporter replaces "." with "_". This caused several metrics to alias, confusing the Prometheus server. Fix it by: * Renaming the "tcp_log_bucket" UMA zone to "tcp_log_id_bucket". Also, rename "tcp_log_node" to "tcp_log_id_node" for consistency. * Not exporting sysctls with "(LEGACY)" in the description. That is used by ZFS sysctls that have been replaced by others, many of which alias to the same Prometheus metric name (like "vfs.zfs.arc_max" and "vfs.zfs.arc.max"). PR: 259607 Reported by: delphij Sponsored by: Axcient Reviewed by: delphij,rew,thj Differential Revision: https://reviews.freebsd.org/D34952 (cherry picked from commit 8c47d8f53854825d8e8591ccd06e32b2c798f81c) --- sys/netinet/tcp_log_buf.c | 33 +++++++++++----------- .../prometheus_sysctl_exporter.c | 11 ++++++-- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/sys/netinet/tcp_log_buf.c b/sys/netinet/tcp_log_buf.c index 0e0b6a35013b..296f2dce2c0f 100644 --- a/sys/netinet/tcp_log_buf.c +++ b/sys/netinet/tcp_log_buf.c @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #define TCP_LOG_EXPIRE_INTVL ((sbintime_t)5 * SBT_1S) bool tcp_log_verbose; -static uma_zone_t tcp_log_bucket_zone, tcp_log_node_zone, tcp_log_zone; +static uma_zone_t tcp_log_id_bucket_zone, tcp_log_id_node_zone, tcp_log_zone; static int tcp_log_session_limit = TCP_LOG_BUF_DEFAULT_SESSION_LIMIT; static uint32_t tcp_log_version = TCP_LOG_BUF_VER; RB_HEAD(tcp_log_id_tree, tcp_log_id_bucket); @@ -99,16 +99,16 @@ SYSCTL_UMA_CUR(_net_inet_tcp_bb, OID_AUTO, log_global_entries, CTLFLAG_RD, &tcp_log_zone, "Current number of events maintained for all TCP sessions"); SYSCTL_UMA_MAX(_net_inet_tcp_bb, OID_AUTO, log_id_limit, CTLFLAG_RW, - &tcp_log_bucket_zone, "Maximum number of log IDs"); + &tcp_log_id_bucket_zone, "Maximum number of log IDs"); SYSCTL_UMA_CUR(_net_inet_tcp_bb, OID_AUTO, log_id_entries, CTLFLAG_RD, - &tcp_log_bucket_zone, "Current number of log IDs"); + &tcp_log_id_bucket_zone, "Current number of log IDs"); SYSCTL_UMA_MAX(_net_inet_tcp_bb, OID_AUTO, log_id_tcpcb_limit, CTLFLAG_RW, - &tcp_log_node_zone, "Maximum number of tcpcbs with log IDs"); + &tcp_log_id_node_zone, "Maximum number of tcpcbs with log IDs"); SYSCTL_UMA_CUR(_net_inet_tcp_bb, OID_AUTO, log_id_tcpcb_entries, CTLFLAG_RD, - &tcp_log_node_zone, "Current number of tcpcbs with log IDs"); + &tcp_log_id_node_zone, "Current number of tcpcbs with log IDs"); SYSCTL_U32(_net_inet_tcp_bb, OID_AUTO, log_version, CTLFLAG_RD, &tcp_log_version, 0, "Version of log formats exported"); @@ -360,7 +360,7 @@ tcp_log_remove_bucket(struct tcp_log_id_bucket *tlb) } TCPID_BUCKET_LOCK_DESTROY(tlb); counter_u64_add(tcp_log_pcb_ids_cur, (int64_t)-1); - uma_zfree(tcp_log_bucket_zone, tlb); + uma_zfree(tcp_log_id_bucket_zone, tlb); } /* @@ -669,7 +669,7 @@ restart: * will unlock the bucket. */ if (tln != NULL) - uma_zfree(tcp_log_node_zone, tln); + uma_zfree(tcp_log_id_node_zone, tln); tln = tp->t_lin; tlb = NULL; bucket_locked = false; @@ -702,7 +702,8 @@ restart: if (*id) { /* Get a new tln, if we don't already have one to reuse. */ if (tln == NULL) { - tln = uma_zalloc(tcp_log_node_zone, M_NOWAIT | M_ZERO); + tln = uma_zalloc(tcp_log_id_node_zone, + M_NOWAIT | M_ZERO); if (tln == NULL) { rv = ENOBUFS; goto done; @@ -756,7 +757,7 @@ refind: /* If we need to add a new bucket, do it now. */ if (tmp_tlb == NULL) { /* Allocate new bucket. */ - tlb = uma_zalloc(tcp_log_bucket_zone, M_NOWAIT); + tlb = uma_zalloc(tcp_log_id_bucket_zone, M_NOWAIT); if (tlb == NULL) { rv = ENOBUFS; goto done_noinp; @@ -803,7 +804,7 @@ refind: #define FREE_NEW_TLB() do { \ TCPID_BUCKET_LOCK_DESTROY(tlb); \ - uma_zfree(tcp_log_bucket_zone, tlb); \ + uma_zfree(tcp_log_id_bucket_zone, tlb); \ counter_u64_add(tcp_log_pcb_ids_cur, (int64_t)-1); \ counter_u64_add(tcp_log_pcb_ids_tot, (int64_t)-1); \ bucket_locked = false; \ @@ -906,7 +907,7 @@ done_noinp: } else TCPID_TREE_UNLOCK_ASSERT(); if (tln != NULL) - uma_zfree(tcp_log_node_zone, tln); + uma_zfree(tcp_log_id_node_zone, tln); return (rv); } @@ -1146,10 +1147,10 @@ tcp_log_init(void) #endif NULL, UMA_ALIGN_PTR, 0); (void)uma_zone_set_max(tcp_log_zone, TCP_LOG_BUF_DEFAULT_GLOBAL_LIMIT); - tcp_log_bucket_zone = uma_zcreate("tcp_log_bucket", + tcp_log_id_bucket_zone = uma_zcreate("tcp_log_id_bucket", sizeof(struct tcp_log_id_bucket), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); - tcp_log_node_zone = uma_zcreate("tcp_log_node", + tcp_log_id_node_zone = uma_zcreate("tcp_log_id_node", sizeof(struct tcp_log_id_node), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); #ifdef TCPLOG_DEBUG_COUNTERS @@ -1258,7 +1259,7 @@ tcp_log_expire(void *unused __unused) tcp_log_free_entries(&tln->tln_entries, &tln->tln_count); /* Free the node. */ - uma_zfree(tcp_log_node_zone, tln); + uma_zfree(tcp_log_id_node_zone, tln); /* Relock the expiry queue. */ TCPLOG_EXPIREQ_LOCK(); @@ -2441,7 +2442,7 @@ no_inp: */ tcp_log_free_entries(&cur_tln->tln_entries, &cur_tln->tln_count); - uma_zfree(tcp_log_node_zone, cur_tln); + uma_zfree(tcp_log_id_node_zone, cur_tln); goto done; } @@ -2463,7 +2464,7 @@ no_inp: } /* No matter what, we are done with the node now. */ - uma_zfree(tcp_log_node_zone, cur_tln); + uma_zfree(tcp_log_id_node_zone, cur_tln); /* * Because we removed this entry from the list, prev_tln diff --git a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c index 9d50c3e58750..e452e305d2bf 100644 --- a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c +++ b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c @@ -498,6 +498,7 @@ oid_print(const struct oid *o, struct oidname *on, bool print_description, struct oidvalue ov; struct oiddescription od; char metric[BUFSIZ]; + bool has_desc; if (!oid_get_format(o, &of) || !oid_get_value(o, &of, &ov)) return; @@ -511,14 +512,20 @@ oid_print(const struct oid *o, struct oidname *on, bool print_description, if (include && regexec(&inc_regex, metric, 0, NULL, 0) != 0) return; + has_desc = oid_get_description(o, &od); + /* + * Skip metrics with "(LEGACY)" in the name. It's used by several + * redundant ZFS sysctls whose names alias with the non-legacy versions. + */ + if (has_desc && strnstr(od.description, "(LEGACY)", BUFSIZ) != NULL) + return; /* * Print the line with the description. Prometheus expects a * single unique description for every metric, which cannot be * guaranteed by sysctl if labels are present. Omit the * description if labels are present. */ - if (print_description && !oidname_has_labels(on) && - oid_get_description(o, &od)) { + if (print_description && !oidname_has_labels(on) && has_desc) { fprintf(fp, "# HELP "); fprintf(fp, "%s", metric); fputc(' ', fp);