Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid connection pool Prometheus metric format (monitor, mpMetrics) #6058

Closed
sdaschner opened this issue Dec 18, 2018 · 4 comments · Fixed by #6110
Closed

Invalid connection pool Prometheus metric format (monitor, mpMetrics) #6058

sdaschner opened this issue Dec 18, 2018 · 4 comments · Fixed by #6110
Assignees
Labels
in:MicroProfile/Metrics release bug This bug is present in a released version of Open Liberty release:19001 team:Lumberjack

Comments

@sdaschner
Copy link

Open Liberty version 18.0.0.4 emits datasource metrics in the Prometheus format under /metrics, if the monitor-1.0, and mpMetrics-1.1 features are enabled.

However, the metrics for the default datasource violate the Prometheus format:

vendor:connectionpool_data_source[_default_data_source]_connection_manager_connection_handles
vendor:connectionpool_data_source[_default_data_source]_connection_manager_create_total
...

This produces an error when Prometheus attempts to scrape the metrics under /metrics:

invalid metric type "_default_data_source]_connection_manager_in_use_time_total_seconds gauge"

Tested with Open Liberty versions: 18.0.0.4-20181123-2100 and 18.0.0.4-20181217-2101.

The invalid metrics format renders the whole Prometheus target unusable, unfortunately.

@tevans78 tevans78 added in:MicroProfile/Metrics bug This bug is not present in a released version of Open Liberty labels Dec 18, 2018
@donbourne
Copy link
Member

@sdaschner , thanks very much for reporting this.

Could you please cut/paste the info from your server.xml relevant to your datasource configuration as well?

@sdaschner
Copy link
Author

Sure:

This is the server.xml of my example project; the database properties are injected from bootstrap.properties:

<?xml version="1.0" encoding="UTF-8"?>
<server description="Config example">

    <featureManager>
        <feature>javaee-8.0</feature>
        <feature>mpMetrics-1.1</feature>
        <feature>monitor-1.0</feature>
    </featureManager>

    <!-- Postgres config-example-db definition -->
    <dataSource id="DefaultDataSource" jdbcDriverRef="postgresql-driver"
                type="javax.sql.ConnectionPoolDataSource" transactional="true">

        <properties serverName="config-example-db" portNumber="5432"
                    databaseName="postgres"
                    user="${config-example.db.username}"
                    password="${config-example.db.password}"/>

    </dataSource>

    <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080" httpsPort="9443"/>
    <keyStore id="defaultKeyStore" password="Liberty"/>

    <basicRegistry id="basic" realm="MicroProfileMetrics">
        <user name="admin" password="admin"/>
        <user name="nonadmin" password="guest"/>
    </basicRegistry>

    <administrator-role>
        <user>admin</user>
    </administrator-role>

</server>

And a file postgres-driver.xml that resides under /defaults/ and sets up the driver:

<?xml version="1.0" encoding="UTF-8"?>
<server description="OpenLiberty Java EE 8 Server">

    <jdbcDriver id="postgresql-driver"
                javax.sql.XADataSource="org.postgresql.xa.PGXADataSource"
                javax.sql.ConnectionPoolDataSource="org.postgresql.ds.PGConnectionPoolDataSource"
                libraryRef="postgresql-library"/>

    <library id="postgresql-library">
        <fileset id="PostgreSQLFileset" dir="/opt/wlp/lib"
                 includes="postgresql-9.4.1212.jar"/>
    </library>

</server>

@fwji
Copy link
Contributor

fwji commented Dec 18, 2018

The cause of the issue is the datasource with id 'DefaultDataSource''s auto-generated jndi name. It gets normalized to data_source[_default_data_source]_connection_manager in Prometheus, which broke the Prometheus format. We need to do some sanitizations of the jndi name to make sure the output will be in compliance with Prometheus format. A temporary workaround is to specify a jndiName field when configuring datasource in the server.xml. For example, the following datasource config will work

<dataSource id="ds2" jdbcDriverRef="DerbyEmbedded" jndiName="jdbc/exampleDS2">
	<properties createDatabase="create" databaseName="exampleDS2"/>
	<connectionManager maxIdleTime="1s" maxPoolSize="100" minPoolSize="1" reapTime="2s"/>
</dataSource>

Thanks for catching the issue as it's a scenario missed from our tests. We'll target the fix for 19.0.0.1

@sdaschner
Copy link
Author

Thanks for the quick response! Yes, the workaround solves this.

@fwji fwji added release bug This bug is present in a released version of Open Liberty and removed Needs member attention bug This bug is not present in a released version of Open Liberty labels Jan 6, 2019
@fwji fwji closed this as completed in #6110 Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:MicroProfile/Metrics release bug This bug is present in a released version of Open Liberty release:19001 team:Lumberjack
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants