Source
xxxxxxxxxx
static int prometheus_query_rows(const zbx_vector_prometheus_row_t *rows, const char *request, const char *output,
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
typedef enum
{
ZBX_PROMETHEUS_CONDITION_OP_EQUAL,
ZBX_PROMETHEUS_CONDITION_OP_REGEX,
ZBX_PROMETHEUS_CONDITION_OP_EQUAL_VALUE,
ZBX_PROMETHEUS_CONDITION_OP_NOT_EQUAL,
ZBX_PROMETHEUS_CONDITION_OP_REGEX_NOT_MATCHED
}
zbx_prometheus_condition_op_t;
/* key-value matching data */
typedef struct
{
/* the key to match, optional - can be NULL */
char *key;
/* the pattern to match */
char *pattern;
/* the condition operations */
zbx_prometheus_condition_op_t op;
}
zbx_prometheus_condition_t;
ZBX_PTR_VECTOR_DECL(prometheus_condition, zbx_prometheus_condition_t *)
/* the prometheus pattern filter */
typedef struct
{
/* metric filter, optional - can be NULL */
zbx_prometheus_condition_t *metric;
/* value filter, optional - can be NULL */
zbx_prometheus_condition_t *value;
/* label filters */
zbx_vector_prometheus_condition_t labels;
}
zbx_prometheus_filter_t;
/* the prometheus metric HELP, TYPE hints in comments */
typedef struct
{
char *metric;
char *type;
char *help;
}
zbx_prometheus_hint_t;
/* indexing support */
typedef struct
{
char *value;
zbx_vector_prometheus_row_t rows;
}
zbx_prometheus_index_t;
/* TYPE, HELP hint hashset support */
static zbx_hash_t prometheus_hint_hash(const void *d)
{
const zbx_prometheus_hint_t *hint = (const zbx_prometheus_hint_t *)d;
return ZBX_DEFAULT_STRING_HASH_FUNC(hint->metric);
}