Skip to content

Commit 212d03d

Browse files
authored
Add/integrations (#127)
* added Integration page for Vercel * added Integration page for Heroku * moved database pages under database section * resolved 404s * fixed heroku page --------- Co-authored-by: simranquirky <simranquirky>
1 parent 2891ee5 commit 212d03d

File tree

13 files changed

+353
-5
lines changed

13 files changed

+353
-5
lines changed

docs/integration/.pages

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ nav:
33
- Integrations Overview: index.md
44
- AWS: aws
55
- Cloudflare: cloudflare.md
6-
- PostgreSQL: postgresql.md
7-
- Snowflake: snowflake.md
6+
- Database: database
87
- Servers: servers
9-
- DevOps : devops
8+
- DevOps : devops
9+
- Application Platform: application-platform
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
nav:
2+
3+
- Vercel: vercel.md
4+
- Heroku: heroku.md
5+
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
---
2+
title: Heroku Application Logs Integration Guide
3+
description: Forward Heroku application logs to OpenObserve using a forwarding app to parse Logplex syslogs into structured JSON.
4+
---
5+
6+
# Integration with Heroku Application Logs
7+
8+
This guide explains how to stream Heroku application logs—including app, router, error, and system logs—into OpenObserve using a forwarding app that parses Logplex syslogs into structured JSON.
9+
10+
## Overview
11+
12+
Heroku’s Logplex consolidates logs from your app (stdout/stderr), router (HTTP requests), and system events (dyno restarts). While convenient, it’s limited by retention length (1,500 lines or one week) and raw text format, which is hard to analyze.
13+
14+
![Heroku logs](../images/app-platforms/heroku-logs.png)
15+
16+
OpenObserve ingests these logs in structured JSON format, enabling fast search, rich visualization, and proactive alerting.
17+
18+
## Steps to Integrate
19+
20+
??? "Prerequisites"
21+
- OpenObserve account ([Cloud](https://cloud.openobserve.ai/web/) or [Self-Hosted](../../../quickstart/#self-hosted-installation))
22+
- **An existing Heroku application** already deployed and generating logs
23+
- Heroku CLI installed and authenticated
24+
- Node.js, npm, Git, and terminal access
25+
26+
??? "Step 1: Retrieve OpenObserve Endpoint and Credentials"
27+
28+
1. In OpenObserve: go to **Data Sources → Custom → Logs** → Syslog-NG section
29+
![Get OpenObserve Ingestion URL and Access Key](../images/app-platforms/fetch-syslogng-token.png)
30+
31+
2. Keep the credentials handy.Construct the Heroku-specific ingestion endpoint:
32+
```
33+
https://api.openobserve.ai/api/<organization_id>/<stream_name/_json
34+
```
35+
36+
??? "Step 2: Build a Forwarding App to Parse and Send Logs"
37+
38+
1. Initialize a new forwarding app:
39+
```bash
40+
mkdir heroku-log-forwarder
41+
cd heroku-log-forwarder
42+
npm init -y
43+
npm install express body-parser node-fetch@2
44+
```
45+
46+
2. Create `index.js` and paste:
47+
48+
```javascript
49+
const express = require('express');
50+
const bodyParser = require('body-parser');
51+
const fetch = require('node-fetch');
52+
53+
const app = express();
54+
app.use(bodyParser.text({ type: '*/*' }));
55+
56+
const OPENOBSERVE_URL = 'https://api.openobserve.ai/api/<organization_id>/heroku_logs/_json';
57+
const OPENOBSERVE_USER = '[email protected]';
58+
const OPENOBSERVE_PASS = 'your_password';
59+
60+
const logRegex = /^(\d+) <\d+>1\s+([\d-:.+]+)\s+host\s+(\w+)\s+(\w+)\.(\d+)\s*-\s*(.*)$/;
61+
const routerRegex = /^(\d+) <\d+>1\s+([\d-:.+]+)\s+host\s+heroku\s+(\w+)\s*-\s+at=info\s+(.*)$/;
62+
63+
app.post('/logs', async (req, res) => {
64+
const rawLogs = req.body.split('\n').filter(log => log.trim());
65+
const enriched = rawLogs.map(log => {
66+
let match = log.match(logRegex);
67+
if (match) {
68+
const [, , timestamp, source, dynoNum, dynoId, message] = match;
69+
return {
70+
app: "your-heroku-app-name",
71+
dyno: `${dynoNum}.${dynoId}`,
72+
message,
73+
source: source.toLowerCase(),
74+
timestamp
75+
};
76+
}
77+
match = log.match(routerRegex);
78+
if (match) {
79+
const [, , timestamp, source, details] = match;
80+
const params = details.split(' ').reduce((acc, pair) => {
81+
const [key, value] = pair.split('=');
82+
acc[key] = value.replace(/^"(.*)"$/, '$1');
83+
return acc;
84+
}, {});
85+
return {
86+
app: "your-heroku-app-name",
87+
dyno: params.dyno,
88+
message: details,
89+
source: source.toLowerCase(),
90+
timestamp,
91+
...params
92+
};
93+
}
94+
console.warn(`Unparsed log: ${log}`);
95+
return { message: log, timestamp: new Date().toISOString() };
96+
});
97+
98+
try {
99+
const resp = await fetch(OPENOBSERVE_URL, {
100+
method: 'POST',
101+
headers: {
102+
'Content-Type': 'application/json',
103+
'Authorization': `Basic ${Buffer.from(`${OPENOBSERVE_USER}:${OPENOBSERVE_PASS}`).toString('base64')}`
104+
},
105+
body: JSON.stringify(enriched)
106+
});
107+
if (!resp.ok) throw new Error(`Ingestion failed: ${resp.status}`);
108+
console.log(`Forwarded ${enriched.length} logs`);
109+
res.sendStatus(200);
110+
} catch (err) {
111+
console.error('Error forwarding logs:', err.message);
112+
res.status(500).send('Forwarding failed');
113+
}
114+
});
115+
116+
app.listen(process.env.PORT || 3000, () => console.log(`Forwarder running on port ${process.env.PORT || 3000}`));
117+
```
118+
119+
3. Update placeholders (`<organization_id>`, credentials, and app name) accordingly
120+
4. Create a proc file `web: node index.js`
121+
5. Update `package.json` file:
122+
```bash
123+
{
124+
"name": "heroku-log-forwarder",
125+
"version": "1.0.0",
126+
"main": "index.js",
127+
"scripts": {
128+
"start": "node index.js"
129+
},
130+
"dependencies": {
131+
"express": "^4.21.2",
132+
"body-parser": "^1.20.3",
133+
"node-fetch": "^2.6.7"
134+
}
135+
}
136+
```
137+
138+
??? "Step 3: Deploy Forwarding App to Heroku and Configure Log Drain"
139+
140+
1. Deploy the forwarding app:
141+
```bash
142+
git init
143+
git add .
144+
git commit -m "Heroku log forwarder"
145+
heroku create heroku-log-forwarder
146+
git push heroku main
147+
```
148+
149+
Note the deployed URL (e.g., `https://heroku-log-forwarder.herokuapp.com`).
150+
151+
2. Configure the log drain from your existing app:
152+
```bash
153+
heroku drains:add "https://heroku-log-forwarder.herokuapp.com/logs" -a <your-heroku-app-name>
154+
```
155+
3. Optionally, reduce sampling rate if you encounter buffer overflows:
156+
```bash
157+
heroku drains:update --sampling-rate 25 <drain-id> -a <your-heroku-app-name>
158+
```
159+
4. Verify drain setup:
160+
```bash
161+
heroku drains -a <your-heroku-app-name>
162+
```
163+
164+
??? "Step 4: Verify Logs in OpenObserve"
165+
166+
1. In OpenObserve, go to **Logs → heroku_logs** and run a query to see structured entries.
167+
168+
![Verfify Heroku logs in Openobserve](https://openobserve.ai/assets/4_view_logs_o2_d5e8e881b2.gif)
169+
170+
## Troubleshooting
171+
172+
??? "**No logs or some log types missing**"
173+
- Check Heroku app logs (More → View logs) to confirm log generation (Router, App, Error types)
174+
- Confirm the drain is active:
175+
```bash
176+
heroku drains -a <your-heroku-app-name>
177+
```
178+
- Tail your forwarder logs for warnings or errors
179+
180+
??? "**Buffer overflow (Error L10)**"
181+
- Reduce sampling rate:
182+
```bash
183+
heroku drains:update --sampling-rate 10 <drain-id> -a <your-heroku-app-name>
184+
```
185+
186+
??? "**Unparsed logs**"
187+
- Review `Unparsed log` warnings in forwarder logs
188+
- Adjust regex patterns in `index.js`
189+
190+
??? "**Truncated logs**"
191+
- Heroku truncates lines >10 KB. Simplify log message content in forwarding app and redeploy
192+
193+
??? "**Slow log delivery**"
194+
- Increase heartbeat interval in `index.js` or reduce traffic volume
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The following user guides provide step-by-step instructions to integrate application platforms and PaaS services with OpenObserve. These integrations allow you to collect logs, metrics, and events directly from your hosting, routing, and developer platforms, enabling unified observability across your applications.
2+
3+
Each guide corresponds to a data source listed in the **Data Sources** section of the OpenObserve user interface.
4+
5+
![Data Sources](../../../docs/images/data-sources.png)
6+
7+
Learn more:
8+
9+
- [Vercel](vercel.md)
10+
- [Heroku](heroku.md)
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: Vercel Application Logs Integration Guide
3+
description: Forward Vercel application logs to OpenObserve using a serverless function for centralized storage, search, and monitoring.
4+
---
5+
6+
# Integration with Vercel Application Logs
7+
8+
This guide explains how to forward Vercel application logs to OpenObserve using a custom serverless function within your Vercel project.
9+
10+
## Overview
11+
12+
Vercel Log Drains allow you to send application, build, and edge function logs to an external destination. By sending them to OpenObserve, you can search, visualize, and set alerts on logs in real time.
13+
This method uses a self-hosted serverless function as a relay to forward logs securely.
14+
15+
## Steps to Integrate
16+
17+
??? "Prerequisites"
18+
- OpenObserve account ([Cloud](https://cloud.openobserve.ai/web/) or [Self-Hosted](../../../quickstart/#self-hosted-installation))
19+
- Vercel project (Pro or Enterprise plan, Log Drains are not available on Hobby)
20+
- Vercel CLI or dashboard access
21+
- Basic Node.js knowledge for modifying serverless functions
22+
23+
??? "Step 1: Get OpenObserve Ingestion URL and Access Key"
24+
25+
1. In OpenObserve: go to **Data Sources → Custom → Logs**
26+
2. Copy the ingestion URL and Access Key
27+
3. Update the URL to include your stream name, for example:
28+
```
29+
https://<your-openobserve-domain>/api/<org_id>/<stream_name>/_json
30+
```
31+
32+
![Get OpenObserve Ingestion URL and Access Key](../images/app-platforms/fetch-token.png)
33+
34+
??? "Step 2: Create a Vercel Serverless Function"
35+
36+
1. In your Vercel project, create a file as `api/logs.js`
37+
2. Paste the following sample code:
38+
39+
```javascript
40+
import https from 'https';
41+
42+
const OPENOBSERVE_URL = 'https://<your-openobserve-domain>/api/<org_id>/<stream_name>/_json';
43+
const API_KEY = '<your_base64_encoded_key>';
44+
const VERCEL_VERIFY_TOKEN = '<your_vercel_verification_token>';
45+
46+
export default async function handler(req, res) {
47+
// Verify Vercel request
48+
if (req.headers['vercel-log-drain-signature'] !== VERCEL_VERIFY_TOKEN) {
49+
return res.status(401).send('Unauthorized');
50+
}
51+
52+
const logs = Array.isArray(req.body) ? req.body : [req.body];
53+
const data = JSON.stringify(logs);
54+
55+
const options = {
56+
method: 'POST',
57+
headers: {
58+
'Authorization': `Basic ${API_KEY}`,
59+
'Content-Type': 'application/json'
60+
}
61+
};
62+
63+
const request = https.request(OPENOBSERVE_URL, options, (response) => {
64+
response.on('data', () => {});
65+
response.on('end', () => res.status(200).send('OK'));
66+
});
67+
68+
request.on('error', (error) => {
69+
console.error(error);
70+
res.status(500).send('Error forwarding logs');
71+
});
72+
73+
request.write(data);
74+
request.end();
75+
}
76+
```
77+
78+
3. Replace placeholders:
79+
- `<your-openobserve-domain>` with your instance
80+
- `<org_id>` and `<stream_name>` from OpenObserve
81+
- `<your_base64_encoded_key>` from OpenObserve
82+
- `<your_vercel_verification_token>` from Vercel
83+
84+
??? "Step 3: Deploy the Function to Vercel"
85+
86+
1. Push your code to trigger deployment
87+
```
88+
git add api/logs.js
89+
git commit -m "Add log drain endpoint for OpenObserve"
90+
git push
91+
```
92+
2. Note the deployed endpoint URL (e.g., `https://your-app.vercel.app/api/logs`)
93+
94+
??? "Step 4: Configure Log Drain in Vercel"
95+
96+
1. Go to **Vercel Dashboard → Your Project → Settings → Log Drains**
97+
2. Add a new Log Drain:
98+
- **Endpoint URL**: Log endpoint URL from Step 3
99+
- **Sources**: Check “Function” and “Edge” for runtime logs; add “Build” for deployment logs if desired.
100+
- **Delivery Format**: Select “JSON”—Vercel’s default, and OpenObserve handles it natively.
101+
3. Save the configuration
102+
103+
![Configure Log Drain in Vercel](https://openobserve.ai/assets%2F4_setup_log_drain_bee0dcc96e.gif)
104+
105+
??? "Step 5: Verify Logs in OpenObserve"
106+
107+
1. Generate some logs by hitting your application endpoints or triggering a deployment
108+
2. In OpenObserve, go to **Logs** → select your stream → click **Run Query**
109+
3. You should see recent log entries from your Vercel app
110+
111+
![Verify Logs in OpenObserve](https://openobserve.ai/assets%2F6_view_logs_o2_45ebd5489c.gif)
112+
113+
## Troubleshooting
114+
115+
??? "**No logs visible?**"
116+
- Check function logs in Vercel
117+
- Verify API key and ingestion URL in the function
118+
- Confirm Vercel Log Drain is enabled and pointing to the correct endpoint
119+
120+
??? "**401 Unauthorized**"
121+
- Ensure the verification token in Vercel matches the one in your function
122+
123+
??? "**Partial logs or missing fields**"
124+
- Inspect incoming payload format in your function logs
125+
- Ensure logs are sent as an array to OpenObserve (`[ {...}, {...} ]`)

docs/integration/database/.pages

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
nav:
2+
3+
- PostgreSQL: postgresql.md
4+
- Snowflake: snowflake.md

docs/integration/database/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The following user guides provide step-by-step instructions to integrate popular databases with OpenObserve. These integrations allow you to collect logs, metrics, and events directly from your database systems, enabling unified observability across your data infrastructure.
2+
3+
Each guide corresponds to a data source listed in the **Data Sources** section of the OpenObserve user interface.
4+
5+
![Data Sources](../../../docs/images/data-sources.png)
6+
7+
Learn more:
8+
9+
- [PostgreSQL](postgresql.md)
10+
- [SnowFlake](snowflake.md)
File renamed without changes.
File renamed without changes.
298 KB
Loading

0 commit comments

Comments
 (0)