diff --git a/domain_admin/api/prometheus_api.py b/domain_admin/api/prometheus_api.py index d6856a3ed1..e987b3e12f 100644 --- a/domain_admin/api/prometheus_api.py +++ b/domain_admin/api/prometheus_api.py @@ -64,22 +64,54 @@ def metrics(): logger.info('success') # 域名数据 @since v1.5.27 + domain_info_fields = [ + "id", + "user_id", + "domain", + "group_id", + "group_name", + "comment", + "domain_registrar", + "domain_registrar_url", + "domain_start_time", + "domain_expire_time", + "is_auto_update", + "is_expire_monitor", + "icp_company", + "icp_licence", + 'tags', + 'real_domain_expire_days', + 'update_time_label', + 'domain_start_date', + 'domain_expire_date', + "create_time", + "update_time", + ] + domain_info_gauge = Gauge( - "domain_info", - "this is a domain info data", - ["domain", "group_name"], + name="domain_info", + documentation="this is a domain info data", + labelnames=domain_info_fields, registry=registry) domain_info_rows = DomainInfoModel.select() - domain_info_lst = [model_to_dict(row, extra_attrs=['real_domain_expire_days']) for row in domain_info_rows] + domain_info_lst = [model_to_dict( + row, + extra_attrs=[ + 'tags', + 'real_domain_expire_days', + 'update_time_label', + 'domain_start_date', + 'domain_expire_date', + ] + ) for row in domain_info_rows] # 分组名 group_service.load_group_name(domain_info_lst) for row in domain_info_lst: domain_info_gauge.labels( - row['domain'], - row['group_name'] + *[row[field] for field in domain_info_fields] ).set(row['real_domain_expire_days']) return Response(prometheus_client.generate_latest(registry), mimetype='text/plain') diff --git a/http/prometheus.http b/http/prometheus.http index e14737123f..7a1048bb95 100644 --- a/http/prometheus.http +++ b/http/prometheus.http @@ -8,6 +8,6 @@ POST {{baseUrl}}/metrics Content-Type: application/json -Authorization: Bearer f60c03bfff8bb42dcf6821542e5fd11e +Authorization: Bearer 27a79ecddc8947c9f5ce658453c45c9b ###