Skip to content

Commit 00620c1

Browse files
adding the apache server example (#36)
* adding the apache server example * Apply suggestions from code review --------- Co-authored-by: प्रथमेश Sonpatki <csonpatki@gmail.com>
1 parent 90e3cff commit 00620c1

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed
+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Monitoring Apache Server Metrics with OpenTelemetry
2+
3+
A guide for setting up Apache Server monitoring using OpenTelemetry Collector with Last9. It collects host metrics, Apache Server metrics and sends them to Last9.
4+
5+
## Installation
6+
7+
### 1. Apache Server Setup
8+
9+
```bash
10+
# Install apache
11+
sudo apt-get update
12+
sudo apt-get install -y apache2
13+
sudo systemctl start apache2
14+
15+
# Verify installation
16+
sudo systemctl status apache2
17+
```
18+
19+
Configure Apache Server:
20+
```bash
21+
sudo nano /etc/apache2/apache2.conf
22+
```
23+
24+
Add the below configuration in the conf file:
25+
```ini
26+
<Location "/server-status">
27+
SetHandler server-status
28+
Require host localhost
29+
</Location>
30+
```
31+
Note: Replace `localhost` with your domain name.
32+
33+
```bash
34+
# Restart Apache
35+
sudo systemctl restart apache2
36+
```
37+
38+
### 2. Install OpenTelemetry Collector
39+
40+
```bash
41+
sudo apt-get update
42+
sudo apt-get -y install wget systemctl
43+
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.110.0/otelcol-contrib_0.110.0_linux_amd64.deb
44+
sudo dpkg -i otelcol-contrib_0.110.0_linux_amd64.deb
45+
```
46+
47+
Configure collector:
48+
```bash
49+
sudo nano /etc/otelcol-contrib/config.yaml
50+
```
51+
52+
Copy the configuration from [here](./otel-config.yaml) and update in `/etc/otelcol-contrib/config.yaml`.
53+
54+
Start collector:
55+
```bash
56+
otelcol-contrib --config /etc/otelcol-contrib/config.yaml
57+
```
58+
59+
## Verification
60+
61+
1. Test exporter:
62+
You can access the following link - http://localhost/server-status in your browser to check the metrics of the apache server
63+
64+
```bash
65+
curl http://localhost/server-status
66+
```
67+
68+
## Troubleshooting
69+
70+
1. Apache issues:
71+
```bash
72+
sudo systemctl status apache2
73+
sudo journalctl -u apache2
74+
```
75+
2. Collector issues:
76+
```bash
77+
sudo systemctl status otelcol-contrib
78+
sudo journalctl -u otelcol-contrib
79+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
receivers:
2+
otlp:
3+
protocols:
4+
grpc:
5+
endpoint: 127.0.0.1:4318
6+
http:
7+
endpoint: 127.0.0.1:4319
8+
apache:
9+
endpoint: "http://localhost:80/server-status?auto"
10+
collection_interval: 30s
11+
12+
processors:
13+
batch:
14+
timeout: 5s
15+
send_batch_size: 10000
16+
send_batch_max_size: 10000
17+
resourcedetection/ec2:
18+
detectors: ["ec2"]
19+
ec2:
20+
# A list of regex's to match tag keys to add as resource attributes can be specified
21+
tags:
22+
# This means you have a tag `Name` associated with the EC2 Instance.
23+
- ^Name$
24+
# This means you have a tag `app` associated with the EC2 Instance.
25+
- ^app$
26+
transform/ec2:
27+
error_mode: ignore
28+
log_statements:
29+
- context: resource
30+
statements:
31+
# Set Service name as the `Name` tag associated with the EC2 Instance. The format is `ec2.tag.<tag_name>`.
32+
- set(attributes["service.name"], attributes["ec2.tag.Name"])
33+
resourcedetection/system:
34+
detectors: ["system"]
35+
system:
36+
hostname_sources: ["os"]
37+
transform/hostmetrics:
38+
metric_statements:
39+
- context: datapoint
40+
statements:
41+
- set(attributes["host.name"], resource.attributes["host.name"])
42+
- set(attributes["cloud.account.id"], resource.attributes["cloud.account.id"])
43+
- set(attributes["cloud.availability_zone"], resource.attributes["cloud.availability_zone"])
44+
- set(attributes["cloud.platform"], resource.attributes["cloud.platform"])
45+
- set(attributes["cloud.provider"], resource.attributes["cloud.provider"])
46+
- set(attributes["cloud.region"], resource.attributes["cloud.region"])
47+
- set(attributes["host.type"], resource.attributes["host.type"])
48+
- set(attributes["host.image.id"], resource.attributes["host.image.id"])
49+
exporters:
50+
otlp/last9:
51+
endpoint: "<LAST9_OTEL_ENDPOINT>"
52+
headers:
53+
"Authorization": "Basic <LAST9_OAUTH_TOKEN>"
54+
debug:
55+
verbosity: detailed
56+
57+
service:
58+
pipelines:
59+
metrics:
60+
receivers: [apache]
61+
processors: [batch, resourcedetection/system, transform/hostmetrics]
62+
exporters: [otlp/last9]

0 commit comments

Comments
 (0)