Skip to content
Snippets Groups Projects
  • dpsutton's avatar
    00530c98
    initial prometheus sketch (#25149) · 00530c98
    dpsutton authored
    * initial prometheus sketch
    
    need env variable to start: MB_PROMETHEUS_SERVER_PORT=9191
    
    sample of output:
    
    ```
    '# HELP jvm_threads_current Current thread count of a JVM
    '# TYPE jvm_threads_current gauge
    jvm_threads_current 81.0
    '# HELP jvm_threads_daemon Daemon thread count of a JVM
    '# TYPE jvm_threads_daemon gauge
    jvm_threads_daemon 36.0
    '# HELP jvm_threads_peak Peak thread count of a JVM
    '# TYPE jvm_threads_peak gauge
    jvm_threads_peak 81.0
    '# HELP jvm_threads_started_total Started thread count of a JVM
    '# TYPE jvm_threads_started_total counter
    jvm_threads_started_total 104.0
    '# HELP jvm_threads_deadlocked Cycles of JVM-threads that are in deadlock waiting to acquire object monitors or ownable synchronizers
    '# TYPE jvm_threads_deadlocked gauge
    jvm_threads_deadlocked 0.0
    ```
    
    request:
    
    ```
    ❯ http localhost:9191/metrics
    HTTP/1.1 200 OK
    Content-Length: 7329
    Content-Type: text/plain; version=0.0.4; charset=utf-8
    Date: Wed, 31 Aug 2022 16:13:38 GMT
    Server: Jetty(9.4.48.v20220622)
    
    '# HELP jvm_gc_collection_seconds Time spent in a given JVM garbage collector in seconds.
    '# TYPE jvm_gc_collection_seconds summary
    jvm_gc_collection_seconds_count{gc="G1 Young Generation",} 41.0
    jvm_gc_collection_seconds_sum{gc="G1 Young Generation",} 0.586
    jvm_gc_collection_seconds_count{gc="G1 Old Generation",} 0.0
    jvm_gc_collection_seconds_sum{gc="G1 Old Generation",} 0.0
    '# HELP jvm_threads_current Current thread count of a JVM
    '# TYPE jvm_threads_current gauge
    ```
    
    * Log on unparseable prometheus port
    
    * Clean up prometheus and save test
    
    * typehint
    
    * Jetty collector
    
    * Reset system to nil when shutting down
    
    * c3p0 stats
    
    * Clean up, document, and add tests
    
    * Error message for failure to bind to port
    
    Starting up with prometheus port set to the main webserver port to get
    the error:
    
    ```
    MB_JETTY_PORT=3006 MB_DB_CONNECTION_URI="postgres://..." \
    MB_PROMETHEUS_SERVER_PORT=3006 java -jar locally-built.jar
    ```
    yields the following error:
    
    ```shell
    2022-09-09 10:08:52,000 INFO metabase.core :: Setting up prometheus metrics
    2022-09-09 10:08:52,002 INFO metabase.prometheus :: Starting prometheus metrics collector
    2022-09-09 10:08:52,016 INFO metabase.prometheus :: Starting prometheus metrics web-server on port 3,006
    2022-09-09 10:08:52,036 ERROR metabase.core :: Metabase Initialization FAILED
    clojure.lang.ExceptionInfo: Failed to initialized Prometheus on port 3,006 {:port 3006}
    [stacktrace ...]
    Caused by: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:3006
    [stacktrace ...]
    Caused by: java.net.BindException: Address already in use
    ```
    
    * Test for error message
    
    * Move prometheus to analytics folder
    
    * Str port so log does not add commas to number
    
    eg:
    > Starting prometheus metrics web-server on port 9,191
    
    * make some test functions private
    
    * docstring on defsetting
    
    * align lets
    
    * ns docstring changes
    
    include the env variable for ease of understanding
    
    * sort ns
    
    * remove some reflection warnings
    
    * reorder FE lines due to some new linter
    
    * Cleanup: i18n descriptions, typo, List/of
    
    * bit more concise c3p0 collection
    
    * no longer need the helper `->array`
    
    * clean up doseq for c3p0 measurements
    initial prometheus sketch (#25149)
    dpsutton authored
    * initial prometheus sketch
    
    need env variable to start: MB_PROMETHEUS_SERVER_PORT=9191
    
    sample of output:
    
    ```
    '# HELP jvm_threads_current Current thread count of a JVM
    '# TYPE jvm_threads_current gauge
    jvm_threads_current 81.0
    '# HELP jvm_threads_daemon Daemon thread count of a JVM
    '# TYPE jvm_threads_daemon gauge
    jvm_threads_daemon 36.0
    '# HELP jvm_threads_peak Peak thread count of a JVM
    '# TYPE jvm_threads_peak gauge
    jvm_threads_peak 81.0
    '# HELP jvm_threads_started_total Started thread count of a JVM
    '# TYPE jvm_threads_started_total counter
    jvm_threads_started_total 104.0
    '# HELP jvm_threads_deadlocked Cycles of JVM-threads that are in deadlock waiting to acquire object monitors or ownable synchronizers
    '# TYPE jvm_threads_deadlocked gauge
    jvm_threads_deadlocked 0.0
    ```
    
    request:
    
    ```
    ❯ http localhost:9191/metrics
    HTTP/1.1 200 OK
    Content-Length: 7329
    Content-Type: text/plain; version=0.0.4; charset=utf-8
    Date: Wed, 31 Aug 2022 16:13:38 GMT
    Server: Jetty(9.4.48.v20220622)
    
    '# HELP jvm_gc_collection_seconds Time spent in a given JVM garbage collector in seconds.
    '# TYPE jvm_gc_collection_seconds summary
    jvm_gc_collection_seconds_count{gc="G1 Young Generation",} 41.0
    jvm_gc_collection_seconds_sum{gc="G1 Young Generation",} 0.586
    jvm_gc_collection_seconds_count{gc="G1 Old Generation",} 0.0
    jvm_gc_collection_seconds_sum{gc="G1 Old Generation",} 0.0
    '# HELP jvm_threads_current Current thread count of a JVM
    '# TYPE jvm_threads_current gauge
    ```
    
    * Log on unparseable prometheus port
    
    * Clean up prometheus and save test
    
    * typehint
    
    * Jetty collector
    
    * Reset system to nil when shutting down
    
    * c3p0 stats
    
    * Clean up, document, and add tests
    
    * Error message for failure to bind to port
    
    Starting up with prometheus port set to the main webserver port to get
    the error:
    
    ```
    MB_JETTY_PORT=3006 MB_DB_CONNECTION_URI="postgres://..." \
    MB_PROMETHEUS_SERVER_PORT=3006 java -jar locally-built.jar
    ```
    yields the following error:
    
    ```shell
    2022-09-09 10:08:52,000 INFO metabase.core :: Setting up prometheus metrics
    2022-09-09 10:08:52,002 INFO metabase.prometheus :: Starting prometheus metrics collector
    2022-09-09 10:08:52,016 INFO metabase.prometheus :: Starting prometheus metrics web-server on port 3,006
    2022-09-09 10:08:52,036 ERROR metabase.core :: Metabase Initialization FAILED
    clojure.lang.ExceptionInfo: Failed to initialized Prometheus on port 3,006 {:port 3006}
    [stacktrace ...]
    Caused by: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:3006
    [stacktrace ...]
    Caused by: java.net.BindException: Address already in use
    ```
    
    * Test for error message
    
    * Move prometheus to analytics folder
    
    * Str port so log does not add commas to number
    
    eg:
    > Starting prometheus metrics web-server on port 9,191
    
    * make some test functions private
    
    * docstring on defsetting
    
    * align lets
    
    * ns docstring changes
    
    include the env variable for ease of understanding
    
    * sort ns
    
    * remove some reflection warnings
    
    * reorder FE lines due to some new linter
    
    * Cleanup: i18n descriptions, typo, List/of
    
    * bit more concise c3p0 collection
    
    * no longer need the helper `->array`
    
    * clean up doseq for c3p0 measurements
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
deps.edn 29.42 KiB