我正在开发一个接受传入HTTP请求并包含用户邮政编码的应用程序。我想跟踪使用度量标准收到的每个邮政编码,以便将其报告给普罗米修斯并在Grafana内部绘图。为每个邮政编码设置一个计数器是没有意义的,但我担心Gauge不合适,而Grafana会错过Prometheus擦除之间的一些数据。关于如何完成这项任务的任何建议?我们确实有记录,但我们需要在Grafana中显示这些信息。
答案 0 :(得分:0)
这更像是一个用于记录的用例,而不是给定基数的指标。
这是标签的用例,但Dropwizard不支持这些。因此,如果您要使用Prometheus执行此操作,我建议您使用带有Counter
DECLARE @root varchar(250);
SET @root = 'AB&C';
DECLARE @index_base bigint;
SET @index_base = 9999;
DECLARE @tbl TABLE
(
[FUNCTION] VARCHAR(20)
,[SUBFUNCTION] VARCHAR(20)
,[LEVEL] VARCHAR(20)
,[ROLE PROFILE] VARCHAR(20)
);
INSERT INTO @tbl
VALUES
('Function 1','Sub Function 1','A','RP1')
,('Function 1','Sub Function 1','A','RP2')
,('Function 1','Sub Function 1','A','RP3')
,('Function 1','Sub Function 1','B','RP4')
,('Function 1','Sub Function 1','C','RP5')
,('Function 1','Sub Function 1','C','RP6')
,('Function 1','Sub Function 1','C','RP9')
,('Function 1','Sub Function 1','D','RP10')
,('Function 1','Sub Function 2','A','RP6')
,('Function 1','Sub Function 2','A','RP11')
,('Function 1','Sub Function 2','A','RP12')
,('Function 1','Sub Function 2','A','RP13')
,('Function 1','Sub Function 3','A','RP14')
,('Function 1','Sub Function 3','A','RP15')
,('Function 1','Sub Function 3','B','RP16')
,('Function 1','Sub Function 3','B','RP17')
,('Function 2','Sub Function 1','A','RP1')
,('Function 2','Sub Function 1','B','RP2')
,('Function 2','Sub Function 1','B','RP18')
,('Function 2','Sub Function 1','B','RP19')
,('Function 2','Sub Function 1','C','RP20')
,('Function 2','Sub Function 3','A','RP21')
,('Function 2','Sub Function 3','B','RP22')
,('Function 2','Sub Function 3','B','RP25')
,('Function 2','Sub Function 3','C','RP26')
,('Function 2','Sub Function 3','C','RP30')
,('Function 2','Sub Function 3','C','RP29')
,('Function 2','Sub Function 4','A','RP31')
,('Function 2','Sub Function 4','A','RP33')
,('Function 2','Sub Function 4','A','RP34')
,('Function 2','Sub Function 4','A','RP38')
,('Function 2','Sub Function 4','A','RP41');
DECLARE @tbl2 TABLE
(
ID bigint
,fullname varchar(max)
,parent varchar(max)
,name varchar(250)
)
INSERT INTO @tbl2
SELECT ROW_NUMBER() OVER (ORDER BY fullname) as ID
,fullname
,parent
,name
FROM
(
SELECT
@root as fullname
,null as parent
,@root as name
UNION
SELECT distinct
@root + [FUNCTION] as fullname
,@root as parent
,[FUNCTION] as name
FROM @tbl
UNION
SELECT distinct
@root + [FUNCTION] + [SUBFUNCTION] as fullname
,@root + [FUNCTION] as parent
,[SUBFUNCTION] as name
FROM @tbl
UNION
SELECT distinct
@root + [FUNCTION] + [SUBFUNCTION] + [LEVEL] as fullname
,@root + [FUNCTION] + [SUBFUNCTION] as parent
,[LEVEL] as name
FROM @tbl
UNION
SELECT distinct
@root + [FUNCTION] + [SUBFUNCTION] + [LEVEL] + [ROLE PROFILE] as fullname
,@root +[FUNCTION] + [SUBFUNCTION] + [LEVEL] as parent
,[ROLE PROFILE] as name
FROM @tbl
) a
SELECT [Id], [Name], [ObjectId], [ParentObjectId]
FROM
(
SELECT a.name as [Id], a.name as [Name], CONVERT(varchar(100), @index_base + a.ID) as [ObjectId], CONVERT(varchar(100), @index_base + b.ID) as [ParentObjectId]
FROM @tbl2 a inner join @tbl2 b ON a.parent = b.fullname
UNION
SELECT @root, @root, CONVERT(varchar(100), @index_base + 1), ''
) n
ORDER BY [ObjectId]
FOR XML PATH('Role')
的{{3}}和邮政编码标签。