Server rental store

Prometheus Configuration

# Prometheus Configuration

This article details the configuration of Prometheus for monitoring a MediaWiki environment. Prometheus is a powerful open-source systems monitoring and alerting toolkit, and integrating it with your MediaWiki infrastructure provides valuable insights into performance and stability. This guide is intended for newcomers to the MediaWiki site and will cover installation, configuration, and basic usage.

== Introduction to Prometheus

Prometheus collects metrics from configured target systems by scraping HTTP endpoints. These metrics are then stored and can be queried using its powerful query language, PromQL. For MediaWiki, we will use an exporter to expose relevant metrics in a format Prometheus can understand. This allows us to monitor key aspects like database performance, cache hits, and web server load. See Special:MyPreferences for personal settings related to monitoring.

== Installation and Setup

The installation process varies based on your operating system. These instructions assume a Debian/Ubuntu-based system, but the principles apply to other distributions. First, download the latest Prometheus release from the official website: [https://prometheus.io/download/](https://prometheus.io/download/).

Once downloaded, extract the archive and move the `prometheus` binary to a suitable location, such as `/usr/local/bin`. Ensure the user running Prometheus has the necessary permissions. You can also consult Manual:Configuration for system-wide configuration settings.

```bash tar -xzf prometheus-*.tar.gz sudo mv prometheus /usr/local/bin ```

Next, create a Prometheus configuration file, typically named `prometheus.yml`. This file defines the targets Prometheus will scrape. Refer to Help:Contents for general help resources.

== Prometheus Configuration File (prometheus.yml)

The `prometheus.yml` file is crucial. Here's a basic example:

```yaml global: scrape_interval: 15s evaluation_interval: 15s

scrape_configs: - job_name: 'mediawiki' static_configs: - targets: ['localhost:9100'] # Replace with your MediaWiki exporter address ```

This configuration scrapes metrics from `localhost` on port `9100`, which is the typical port for a MediaWiki exporter. It’s important to replace `localhost:9100` with the actual address and port of your exporter. Consult Manual:Upgrade for upgrading to new versions.

== MediaWiki Exporter Configuration

A MediaWiki exporter is required to translate MediaWiki's internal metrics into a format Prometheus can understand. Several exporters are available, but a common choice is the `mediawiki_exporter`.

Exporter Installation

Install the `mediawiki_exporter` using your preferred method (e.g., Go get, pre-built binaries).

```bash go get github.com/prometheus/mediawiki_exporter ```

Exporter Configuration

The `mediawiki_exporter` requires a `config.yml` file to connect to your MediaWiki database. Here's an example:

```yaml mediawiki: database_type: mysql host: localhost port: 3306 user: wikiuser password: wikipassword database: wiki table_prefix: mw_ ```

Replace the placeholder values with your actual database credentials. The `table_prefix` should match the prefix used by your MediaWiki installation. See Manual:Database for more information on database configuration.

Running the Exporter

Run the exporter, pointing it to your configuration file:

```bash mediawiki_exporter --config.file=config.yml ```

== Key Metrics to Monitor

Prometheus can collect a wide range of metrics. Here are some essential ones for monitoring a MediaWiki installation:

Metric Name Description Importance
`mediawiki_cache_hits` Number of cache hits. High
`mediawiki_cache_misses` Number of cache misses. High
`mediawiki_db_queries_total` Total number of database queries. Medium
`mediawiki_db_query_time_seconds` Database query execution time. High
`mediawiki_page_views_total` Total number of page views. Low
`mediawiki_user_sessions_active` Number of active user sessions. Medium

These metrics can be visualized using Grafana. See Help:FAQ for frequently asked questions.

== Grafana Integration

Grafana is a popular open-source data visualization tool that integrates seamlessly with Prometheus. To integrate Grafana, you'll need to add Prometheus as a data source.

1. Open Grafana's web interface. 2. Navigate to "Configuration" -> "Data Sources". 3. Click "Add data source". 4. Select "Prometheus". 5. Enter the Prometheus server URL (e.g., `http://localhost:9090`). 6. Click "Save & Test".

Once configured, you can create dashboards to visualize your MediaWiki metrics. Consider exploring pre-built Grafana dashboards for MediaWiki, or create your own tailored to your specific needs. Refer to Special:Search to find existing dashboards.

== Advanced Configuration

For more complex deployments, consider the following:

⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️