github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/doc/metrics.md (about)

     1  # QuickFeed Metrics Collection
     2  
     3  Statistics about specific gRPC methods is provided by the QuickFeed via:
     4  
     5  ```sh
     6  % curl 127.0.0.1:9097/stats
     7  ```
     8  
     9  ## Prometheus
    10  
    11  Prometheus [documentation](https://prometheus.io/docs/introduction/overview/).
    12  
    13  ### Installing on macOS or Linux with Homebrew
    14  
    15  ```sh
    16  % brew install prometheus
    17  % export ETC=/usr/local/etc                  # macOS
    18  % export ETC=/home/linuxbrew/.linuxbrew/etc  # Linux
    19  % vim $ETC/prometheus.yml
    20  ```
    21  
    22  Edit the file as follows:
    23  
    24  ```yaml
    25  global:
    26    scrape_interval: 15s
    27  
    28  scrape_configs:
    29    - job_name: "prometheus"
    30      static_configs:
    31      - targets: ["localhost:9090"]
    32  
    33    - job_name: "quickfeed"
    34      static_configs:
    35      - targets: ["localhost:9097"]
    36  ```
    37  
    38  If you want to access the Prometheus query interface externally, you need to edit the arguments passed to the prometheus service.
    39  
    40  ```sh
    41  % vim $ETC/prometheus.args
    42  ```
    43  
    44  The default is to access the query interface via localhost.
    45  
    46  ```sh
    47  --web.listen-address=127.0.0.1:9090
    48  ```
    49  
    50  However, here is an example with the `uis.itest.run` server.
    51  Note that port 9090 is blocked in the campus firewall, so the Prometheus interface cannot be accessed from outside.
    52  
    53  ```sh
    54  --web.listen-address=uis.itest.run:9090
    55  ```
    56  
    57  After making changes to the configuration or command line arguments, you need to restart the prometheus service:
    58  
    59  ```sh
    60  % brew services restart prometheus
    61  ```
    62  
    63  Then you can navigate to the Prometheus query interface at [`localhost:9090`](http://localhost:9090) or [`uis.itest.run:9090`](http://uis.itest.run:9090).
    64  Here you can search for both prometheus and quickfeed specific metrics of interest.
    65  Here is a list of quickfeed-specific keywords:
    66  
    67  ```yaml
    68  quickfeed_method_response_time
    69  quickfeed_method_accessed
    70  quickfeed_method_responded
    71  quickfeed_method_failed
    72  quickfeed_login_attempts
    73  quickfeed_clone_repositories_time
    74  quickfeed_repository_validation_time
    75  quickfeed_test_execution_time
    76  quickfeed_test_execution_attempts
    77  quickfeed_test_execution_failed
    78  quickfeed_test_execution_failed_with_output
    79  quickfeed_test_execution_failed_to_extract_results
    80  quickfeed_test_execution_succeeded
    81  ```
    82  
    83  You can also query the current aggregate statistics directly:
    84  
    85  ```sh
    86  % curl 127.0.0.1:9097/stats
    87  ```
    88  
    89  ## Grafana
    90  
    91  Grafana imports the data collected by Prometheus and offers multiple visualization options.
    92  Most importantly, it can plot data from several metrics on the same graph, and also allows using predefined queries in Prometheus' query language `PromQL`.
    93  Grafana runs on `localhost:3000` by default.
    94  
    95  For additional [documentation](https://grafana.com/docs/grafana/latest/).
    96  
    97  ### Installing on macOS or Linux with Homebrew
    98  
    99  ```sh
   100  % brew install grafana
   101  % brew services restart grafana
   102  ```
   103  
   104  The default user and password is `admin`.
   105  The password must be changed before using.