> ## Documentation Index
> Fetch the complete documentation index at: https://docs.futurex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Install and configure Prometheus

> Detailed instructions for installing, configuring, and running Prometheus for VirtuCrypt metrics.

<Note>
  The instructions for downloading, installing, configuring, and running Prometheus locally in this section assume Unix-like systems, such as Linux and MacOS, but the process is similar for Windows with minor changes.
</Note>

Perform the following tasks to install and configure Prometheus:

1. Download Prometheus.
2. Extract the archive.
3. Extract the certificate, key, and certificate chain.
4. Configure Protheus.
5. Run Prometheus.

## Download Prometheus

<Steps>
  <Step>
    Open your web browser and go to the official Prometheus download page at [**https://prometheus.io/download/**](https://prometheus.io/download/).
  </Step>

  <Step>
    Find the appropriate version for your operating system under the **Prometheus** section and select it to start the download.
  </Step>
</Steps>

## Extract the archive

Perform the following steps to extract the downloaded archive:

<Steps>
  <Step>
    After the download finishes, open your terminal.
  </Step>

  <Step>
    Go to the directory where you downloaded the Prometheus archive.
  </Step>

  <Step>
    Extract the downloaded file using the following tar command:

    ```shell title="Terminal" expandable lines wrap theme={null}
      tar xvfz prometheus-*.tar.gz
    ```
  </Step>

  <Step>
    This command creates a new directory named something similar to `prometheus-2.x.x`. Run the following command to go this directory:

    ```shell title="Terminal" expandable lines wrap theme={null}
      cd prometheus-*
    ```
  </Step>
</Steps>

## Extract the certificate, key, and certificate chain

In a terminal, perform the following steps in OpenSSL to extract the client certificate, client private key, and CA certificate tree from the PKCS #12 file you downloaded in the VIP:

<Note>
  Each of the following commands prompts for the PKCS #12 file password.
</Note>

<Steps>
  <Step>
    Extract the client certificate:

    ```shell title="Terminal" expandable lines wrap theme={null}
      openssl pkcs12 -in pki.p12 -clcerts -nokeys -out clientcert.pem
    ```
  </Step>

  <Step>
    Extract the client private key:

    ```shell title="Terminal" expandable lines wrap theme={null}
      openssl pkcs12 -in pki.p12 -nocerts -nodes -out clientkey.pem
    ```
  </Step>

  <Step>
    Extract the CA certificate chain:

    ```shell expandable lines wrap title="Shell" theme={null}
    openssl pkcs12 -in certificate.p12 -cacerts -nokeys -out cacert.pem
    ```
  </Step>
</Steps>

## Configure Prometheus

To configure the Prometheus configuration file (including the client certificate, client private key, and CA certificate chain PEM files), perform the following steps:

<Steps>
  <Step>
    Create a file to contain the configuration settings for Prometheus in the extracted **Prometheus** directory. Name it `prometheus.yml`.
  </Step>

  <Step>
    Edit the file with the appropraite setting for your use case.

    <Check>
      This is an example configuration that instructs Prometheus to monitor a VirtuCrypt endpoint at `us01crypto01test.virtucrypt.com` on port `1234.` Refer to [Appendix A - VirtuCrypt endpoints](./Appendix_A_-_VirtuCrypt_endpoints) for the full list of public VirtuCrypt endpoints.

      ```yaml expandable lines wrap title="YAML" theme={null}
      global:
        scrapeinterval:     3s

        externallabels:
            monitor: 'virtucrypt'

      scrapeconfigs:
        - jobname: 'prometheus'
          staticconfigs:
            - targets: ['localhost:9090']

        - jobname: 'TLSTest'
          metricspath: '/federate'
          params:
            'match[]':
              - '{name=~".+"}'
          staticconfigs:
            - targets: ['us01crypto01test.virtucrypt.com:1234']
          scheme: 'https'
          tlsconfig:
            cafile: '/certs/cacerts.pem'
            certfile: '/certs/clientcert.pem'
            key_file: '/certs/clientkey.pem'
      ```
    </Check>
  </Step>

  <Step>
    Save the `prometheus.yml` file and close your text editor.
  </Step>
</Steps>

## Run Prometheus

Run the following command to execute the Prometheus binary:

```shell expandable lines wrap title="Shell" theme={null}
./prometheus --config.file=prometheus.yml
```

<Check>
  Prometheus should now be running and available at [http://localhost:9090/](http://localhost:9090/) by default.
</Check>
