-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
52 lines (46 loc) · 1.17 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Hono } from 'hono'
import { logpost } from './src/index.js'
const app = new Hono()
app.use('*',
// console.log() (default)
logpost(),
// New Relic
logpost({
type: 'newrelic',
newrelic: {
region: 'us', // 'us'|'eu'|'gov'
// Or endpoint: 'https://log-api.newrelic.com/log/v1',
key: '<API Key (INGEST - LICENSE)>',
body: async (req) => {
return {
timestamp: Date.now(),
cf: req.cf,
hostname: req.url,
headers: Object.fromEntries(req.headers),
}
}
}
})
// Datadog
logpost({
type: 'datadog',
datadog: {
region: 'ap1', // 'us1'|'us3'|'us5'|'eu1'|'ap1'|'gov'
// Or endpoint: 'https://http-intake.logs.ap1.datadoghq.com/api/v2/logs',
key: '<API Key>',
body: async (req) => {
return {
ddsource: 'logpost',
ddtags: 'env:production',
timestamp: Date.now(),
hostname: req.url.hostname,
path: req.url.pathname,
cf: req.cf,
headers: Object.fromEntries(req.headers)
}
}
}
})
)
app.get('/', (c) => c.text('Hello Cloudflare Workers!\n'))
export default app