1073595b0SAdam Hornacek /* 2073595b0SAdam Hornacek * CDDL HEADER START 3073595b0SAdam Hornacek * 4073595b0SAdam Hornacek * The contents of this file are subject to the terms of the 5073595b0SAdam Hornacek * Common Development and Distribution License (the "License"). 6073595b0SAdam Hornacek * You may not use this file except in compliance with the License. 7073595b0SAdam Hornacek * 8073595b0SAdam Hornacek * See LICENSE.txt included in this distribution for the specific 9073595b0SAdam Hornacek * language governing permissions and limitations under the License. 10073595b0SAdam Hornacek * 11073595b0SAdam Hornacek * When distributing Covered Code, include this CDDL HEADER in each 12073595b0SAdam Hornacek * file and include the License file at LICENSE.txt. 13073595b0SAdam Hornacek * If applicable, add the following below this CDDL HEADER, with the 14073595b0SAdam Hornacek * fields enclosed by brackets "[]" replaced with your own identifying 15073595b0SAdam Hornacek * information: Portions Copyright [yyyy] [name of copyright owner] 16073595b0SAdam Hornacek * 17073595b0SAdam Hornacek * CDDL HEADER END 18073595b0SAdam Hornacek */ 19073595b0SAdam Hornacek 20073595b0SAdam Hornacek /* 21073595b0SAdam Hornacek * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 22073595b0SAdam Hornacek */ 23073595b0SAdam Hornacek package org.opengrok.web.servlet; 24073595b0SAdam Hornacek 25*aa6abf42SAdam Hornacek import jakarta.servlet.annotation.WebServlet; 26*aa6abf42SAdam Hornacek import jakarta.servlet.http.HttpServlet; 27*aa6abf42SAdam Hornacek import jakarta.servlet.http.HttpServletRequest; 28*aa6abf42SAdam Hornacek import jakarta.servlet.http.HttpServletResponse; 29073595b0SAdam Hornacek import org.opengrok.indexer.Metrics; 30073595b0SAdam Hornacek 31073595b0SAdam Hornacek import java.io.IOException; 32073595b0SAdam Hornacek import java.io.PrintWriter; 33073595b0SAdam Hornacek 34073595b0SAdam Hornacek @WebServlet("/metrics/prometheus") 35073595b0SAdam Hornacek public class MetricsServlet extends HttpServlet { 36073595b0SAdam Hornacek 37181b571eSAdam Hornacek private static final long serialVersionUID = 0L; 38181b571eSAdam Hornacek 39073595b0SAdam Hornacek @Override doGet(final HttpServletRequest req, final HttpServletResponse resp)40073595b0SAdam Hornacek protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { 41073595b0SAdam Hornacek try (PrintWriter pw = resp.getWriter()) { 420d7ace53SVladimir Kotal pw.print(Metrics.getPrometheusRegistry().scrape()); 43073595b0SAdam Hornacek } 44073595b0SAdam Hornacek } 45073595b0SAdam Hornacek } 46