Configuring the TimesTen Exporter and Prometheus with No Authentication

This example first illustrates how to configure Prometheus without authentication. It then uses the ttExporter utility to start the TimesTen exporter. The -insecure option of the ttExporter utility is used to denote no authentication. After Prometheus is configured and the Exporter is started, Prometheus can then scrape the TimesTen metrics that the Exporter exposes.

  1. Configure Prometheus to scrape metrics from the TimesTen exporter by modifying the scrape_config block of the Prometheus configuration file (prometheus.yml, in this example).
    Modify these parameters in the scrape_configs block of the Prometheus configuration file (prometheus.yml, in this example):
    • job_name: Specify the job name assigned to scrape the metrics (tt_12346, in this example).
    • metrics_path: The Exporter uses /metrics as the HTTP resource path, which is also the Prometheus default. Therefore, you do not need to set the metrics_path parameter.
    • scheme: The Exporter uses the HTTP protocol scheme which is the scheme that is used for no authentication. This is also the Prometheus default. Therefore, you do not need to set the scheme parameter.
    • static_configs section: You must specify the name of the host and the port number for the targets parameter. The host is the server that Exporter will run on and the port number is the port that the Exporter will listen on (myhost:12346, in this example).

      Note:

      The port number must be the same as the port number you use to start the Exporter.
    vi prometheus.yml
    ...
    scrape_configs:
    - job_name: 'tt_12346'
      # metrics_path defaults to '/metrics'
      # scheme defaults to 'http'.
      static_configs:
        - targets: ['myhost:12346']
    ...
  2. Use the ttExporter utility to start the Exporter. Specify the -insecure and -port options. Both of these options are required. Ensure to specify the same port as what was specified in the Prometheus configuration file (12346, in this example). Optionally, specify the -pid-file option to store the process ID of ttExporter in a file. In this example, the file is /tmp/ttexporter.pid2 and the process ID is 942.
    % ttExporter -insecure -port 12346 -pid-file /tmp/ttExporter2.pid
    % cat /tmp/ttexporter2.pid
    942
  3. Optional: From your browser, enter http://myhost:12346/metrics. This enables you to verify that the Exporter has converted the TimesTen metrics into the form required by Prometheus. See The Metrics Supported by the TimesTen Exporter for the supported TimesTen metrics.
    In browser: http://myhost:12346/metrics
    ...
    # HELP timesten_perm_in_use_bytes Bytes of permanent space used
    # TYPE timesten_perm_in_use_bytes gauge
    timesten_perm_in_use_bytes{dsn="mydsn",instancename="myinstance"} 20385792
    # HELP timesten_perm_in_use_high_water_bytes Maximum bytes of permanent space used
    # TYPE timesten_perm_in_use_high_water_bytes gauge
    timesten_perm_in_use_high_water_bytes{dsn="mydsn",instancename="myinstance"} 20385792
    ...
  4. Optional: This step illustrates that you can stop the Exporter. This terminates the ttExporter process. Prometheus no longer scrapes the endpoint. Recall that the -pid-file option was specified when you started the Exporter. Use the Linux pkill -F command to terminate the process ID. Recall the example stores the process ID in the /tmp/ttexporter2.pid file and that the process ID is 942.
    % pkill -F /tmp/ttexporter2.pid
    % cat /tmp/ttexporter2.pid
    942
    % ps 942
      PID TTY      STAT   TIME COMMAND
    
You successfully configured Prometheus and started the Exporter. Prometheus is scraping the TimesTen metrics that the Exporter exposes at the /metrics endpoint. Prometheus continues to scrape the TimesTen metrics until you stop the Exporter.