Commit 33e7ce65 authored by Ramon Nou's avatar Ramon Nou
Browse files

ifdef Prometheus, and CMAKE

parent 142115a8
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
  Parallax ([!110](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/110)).
    - Added support to use multiple metadata backends.
    - Added `--clean-rootdir-finish` argument to remove rootdir/metadir at the end when the daemon finishes.
- Added Prometheus Ouput ([!132](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/132))
  - New option to define gateway --prometheus-gateway <gateway:port>
  - Prometheus output is optional with "GKFS_ENABLE_PROMETHEUS"

### Changed

+6 −0
Original line number Diff line number Diff line
@@ -201,6 +201,12 @@ if (GKFS_CHUNK_STATS)
endif ()
message(STATUS "[gekkofs] Gather Chunk Stats: ${GKFS_CHUNK_STATS}")

option(GKFS_ENABLE_PROMETHEUS "Enable Prometheus Push " OFF)
if(GKFS_ENABLE_PROMETHEUS)
    add_definitions(-DGKFS_ENABLE_PROMETHEUS)
endif ()
message(STATUS "[gekkofs] Prometheus Output: ${GKFS_ENABLE_PROMETHEUS}")

configure_file(include/common/cmake_configure.hpp.in include/common/cmake_configure.hpp)


+4 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ Options:
                              Note, parallaxdb creates a file called rocksdbx with 8GB created in metadir.
  --parallaxsize TEXT         parallaxdb - metadata file size in GB (default 8GB), used only with new files
  --output-stats TEXT         Enables the output of the stats on the FILE (each 10s) for debug
  --prometheus-gateway TEXT   Defines the ip:port of the Prometheus Push gateway
  --version                   Print version and exit.
```

@@ -238,6 +239,9 @@ To enable it use the `-DGKFS_ENABLE_PARALLAX:BOOL=ON` option, you can also disab

Once it is enabled, `--dbbackend` option will be functional.

### Stats
Pushing stats to Prometheus is enabled with the `-DGKFS_ENABLE_PROMETHEUS` and the setup of the `--output-stats <FILE>`. 
Without the last one, the push to the gateway is disabled.

### Acknowledgment

+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ Options:
                              Note, parallaxdb creates a file called rocksdbx with 8GB created in metadir.
  --parallaxsize TEXT         parallaxdb - metadata file size in GB (default 8GB), used only with new files
  --output-stats TEXT         Outputs the stats to the file each 10s.
  --prometheus-gateway TEXT   Defines the ip:port of the Prometheus Push gateway
  --version                   Print version and exit.
````

+24 −10
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@
#include <fstream>


// PROMETHEUS
// PROMETHEUS includes
#ifdef GKFS_PROMETHEUS
#include <prometheus/counter.h>
#include <prometheus/summary.h>
#include <prometheus/exposer.h>
@@ -52,6 +53,9 @@
#include <prometheus/gateway.h>

using namespace prometheus;
#endif


/**
 * Provides storage capabilities to provide stats about GekkoFS
 * The information is per server.
@@ -171,16 +175,15 @@ private:
    dump(std::ofstream& of);


    // Prometheus structs
    std::shared_ptr<Exposer> exposer;
    ///< Push
    std::shared_ptr<Gateway> gateway;
    std::shared_ptr<Registry> registry;
    Family<Counter>* family_counter;
    Family<Summary>* family_summary;
// Prometheus Push structs
#ifdef GKFS_PROMETHEUS
    std::shared_ptr<Gateway> gateway;   ///< Prometheus Gateway
    std::shared_ptr<Registry> registry; ///< Prometheus Counters Registry
    Family<Counter>* family_counter;    ///< Prometheus IOPS counter
    Family<Summary>* family_summary;    ///< Prometheus SIZE counter
    std::map<IOPS_OP, Counter*> IOPS_Prometheus;
    std::map<SIZE_OP, Summary*> SIZE_Prometheus;

#endif

public:
    /**
@@ -188,7 +191,8 @@ public:
     * @param output_thread creates an aditional thread that outputs the stats
     * @param filename file where to write the output
     */
    Stats(bool output_thread, std::string filename);
    Stats(bool output_thread, std::string filename,
          std::string prometheus_gateway);

    /**
     * @brief Destroys the class, and any associated thread
@@ -196,6 +200,16 @@ public:
     */
    ~Stats();


    /**
     * @brief Set the up Prometheus gateway and structures
     *
     * @param gateway_ip
     * @param gateway_port
     */
    void
    setup_Prometheus(std::string gateway_ip, std::string gateway_port);

    /**
     * @brief Adds a new read access to the chunk/path specified
     *
Loading