반응형

K8S 환경에서 prometheus 모니터링이 가능하도록 하려면 아래와 같이 리버스 프록시를 설정해야 한다.
http 포트 8080의 /metrics 호출 시 management 9990의 /metrics 로 전달

Source url Target url
http://$HOSTNAME:8080/metrics http://$HOSTNAME:9990/metrics

 

standalone-ha.xml

...
        <subsystem xmlns="urn:jboss:domain:undertow:12.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other" statistics-enabled="true">
            <buffer-cache name="default"/>
            <server name="default-server">
                <ajp-listener name="ajp" socket-binding="ajp" worker="ajp-worker"/>
                <http-listener name="default" socket-binding="http" no-request-timeout="10000" disallowed-methods="PUT DELETE TRACE OPTIONS" redirect-socket="https" enable-http2="true"/>
                <https-listener name="https" socket-binding="https" ssl-context="applicationSSC" enable-http2="true"/>
                <host name="default-host" alias="localhost">
                    <location name="/" handler="welcome-content"/>
                    <!-- metric url 설정 -->
                    <location name="/metrics" handler="management_proxy"/>
                    <access-log pattern="%{i,X-Forwarded-For} %t %m %s %T %b %D %u %r" directory="${jboss.server.log.dir}" prefix="access_log" suffix=".log"/>
                    <filter-ref name="server-header"/>
                    <filter-ref name="x-powered-by-header"/>
                    <filter-ref name="stuck"/>
                    <http-invoker http-authentication-factory="application-http-authentication"/>
                </host>
            </server>
            <servlet-container name="default">
                <jsp-config x-powered-by="false"/>
                <websockets/>
            </servlet-container>
            <handlers>
                <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
                <!-- reverse proxy hander 설정 -->
                <reverse-proxy name="management_proxy">
                    <host name="metrics" outbound-socket-binding="management" scheme="http" path="/metrics"/>
                </reverse-proxy>
            </handlers>
            <filters>
                <response-header name="server-header" header-name="Server" header-value="_"/>
                <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="_"/>
                <expression-filter name="stuck" expression="blocking; stuck-thread-detector(600)"/>
            </filters>
            <application-security-domains>
                <application-security-domain name="other" security-domain="ApplicationDomain"/>
            </application-security-domains>
        </subsystem>


...
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
        <socket-binding name="http" port="${jboss.http.port:8080}"/>
        <socket-binding name="https" port="${jboss.https.port:8443}"/>
        <socket-binding name="jgroups-mping" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/>
        <socket-binding name="jgroups-tcp" port="7600"/>
        <socket-binding name="jgroups-tcp-fd" interface="private" port="57600"/>
        <socket-binding name="jgroups-udp" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/>
        <socket-binding name="jgroups-udp-fd" interface="private" port="54200"/>
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
        <socket-binding name="modcluster" multicast-address="${jboss.modcluster.multicast.address:224.0.1.105}" multicast-port="23364"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="${jboss.mail.server.host:localhost}" port="${jboss.mail.server.port:25}"/>
        </outbound-socket-binding>
        <!-- management socket 설정 -->
        <outbound-socket-binding name="management">
            <remote-destination host="${jboss.bind.address.management}" port="9990"/>
        </outbound-socket-binding>
    </socket-binding-group>​

 

+ Recent posts