Skip to content

Commit

Permalink
add --grouping_key for monitor (#476)
Browse files Browse the repository at this point in the history
Co-authored-by: baishihao <baishihao@sensetime.com>
Co-authored-by: shihaobai <42648726+shihaobai@users.noreply.github.com>
Co-authored-by: hiworldwzj <30762946+hiworldwzj@users.noreply.github.com>
  • Loading branch information
4 people committed Jul 25, 2024
1 parent b5815a4 commit b41aacf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lightllm/server/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ def main():
)
parser.add_argument("--metric_gateway", type=str, default=None, help="address for collecting monitoring metrics")
parser.add_argument("--job_name", type=str, default="lightllm", help="job name for monitor")
parser.add_argument(
"--grouping_key", action="append", default=[], help="grouping_key for the monitor in the form key=value"
)
parser.add_argument("--push_interval", type=int, default=10, help="interval of pushing monitoring metrics")
parser.add_argument(
"--enable_monitor_auth", action="store_true", help="Whether to open authentication for push_gateway"
Expand Down
17 changes: 15 additions & 2 deletions lightllm/server/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def __init__(self, args):
self.gateway_url = args.metric_gateway
self.registry = CollectorRegistry()
self.job_name = args.job_name
self.grouping_key = {}
if args.grouping_key:
for item in args.grouping_key:
key, value = item.split("=")
self.grouping_key[key] = value
self.auth = args.enable_monitor_auth
self.init_metrics(args)

Expand Down Expand Up @@ -127,6 +132,14 @@ def gauge_set(self, name, value):
def push_metrices(self):
if self.gateway_url is not None:
if self.auth:
push_to_gateway(self.gateway_url, job=self.job_name, registry=self.registry, handler=my_auth_handler)
push_to_gateway(
self.gateway_url,
job=self.job_name,
grouping_key=self.grouping_key,
registry=self.registry,
handler=my_auth_handler,
)
else:
push_to_gateway(self.gateway_url, job=self.job_name, registry=self.registry)
push_to_gateway(
self.gateway_url, job=self.job_name, grouping_key=self.grouping_key, registry=self.registry
)

0 comments on commit b41aacf

Please sign in to comment.