flownative / flow-prometheus-flow-metrics

Neos Flow Metrics Exporter for Prometheus
MIT License
0 stars 2 forks source link

Migration to a PSR-15 Middleware for Flow 8 compatibility #2

Open auwaerter opened 1 week ago

auwaerter commented 1 week ago

I've tried to replace the component chain with a PSR-15 middleware, so it is compatible with Flow 8.

For this, i've touched the original HttpMetricsCollectorComponent.php and modified it the following way. In addition, i've changed the original Settings.Http.yaml to the following, to register it as a middleware.

I've understood, that for this package to run i need to have flownative/prometheus v1.2.0 installed and configured. That's what i did with some global configuration for my Neos project:

Flownative\Prometheus\DefaultCollectorRegistry:
  arguments:
    1:
      object: Flownative\Prometheus\Storage\RedisStorage

Flownative\Prometheus\Storage\RedisStorage:
  arguments:
    1:
      value:
        hostname: 'redis-service'
        port: '6379'
        password: 'xxxx'
        database: 8
        ignoreConnectionErrors: false

Flownative\Prometheus\Http\MetricsExporterMiddleware:
  arguments:
    1:
      value:
        ## Path at which metrics are published for scraping
        telemetryPath: '/metrics'

However, beside receiving the message # Flownative Prometheus Metrics Exporter: There are currently no metrics with data to export. when i'm opening https://host/metrics also the redis database seems to be empty:

redis-cli
auth XXX
SELECT 8
127.0.0.1:6379[8]> KEYS *
(empty array)
127.0.0.1:6379[8]>

This package does not seem to be touched for quite some time, so i'm wondering if it is still maintained - or if i should move to something else instead. Could there be any configuration issue on my side?

Any help is appreciated! :)

auwaerter commented 1 week ago

I think i've found the issue.

Seems like my configuration settings posted above e.g. Objects.yaml was not read somehow when i've added it with the name neos-root/Configuration/Production/Settings.Prometheus.yaml. I found out, as i've tested it with adding basicAuth and it was not changing the access of the /metrics path.

It started working as i was overwriting the file neos-root/Packages/Application/Flownative.Prometheus/Configuration/Objects.yaml and added the basicAuth there.

As i don't want to overwrite and content of a package, i've renamed tmy Settings.Prometheus.yaml to Objects.yaml, as suggested in the documentation. Didn't expected it to be that sensitive regarding the naming. I will try to prepare a PR for this.

kitsunet commented 1 week ago

Hey, good find! Indeed Objects (configuration) and settings (and e.g. routes) are different types of configuration that are handled differently by the configuration manager and each relies on respective naming of the Files. So anything Settings.*.yaml will end up as Settings, etc. Thanks for taking care of the version update, we'll checkout the PR ASAP.