-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added in even more query templates, added template filtering
- Loading branch information
Showing
6 changed files
with
65 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 43 additions & 5 deletions
48
studio/components/interfaces/Settings/Logs/Logs.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,63 @@ | ||
import { LogTemplate } from '.' | ||
import { LogTemplate, LogType } from '.' | ||
|
||
export const TEMPLATES: LogTemplate[] = [ | ||
{ label: 'Recent Errors', mode: 'simple', searchString: '[Ee]rror|\\s[45][0-9][0-9]\\s' }, | ||
{ | ||
label: 'Recent Errors', | ||
mode: 'simple', | ||
searchString: '[Ee]rror|\\s[45][0-9][0-9]\\s', | ||
for: ['api'], | ||
}, | ||
{ | ||
label: 'Commits', | ||
mode: 'simple', | ||
searchString: 'COMMIT', | ||
for: ['database'], | ||
}, | ||
|
||
{ | ||
label: '10 Minutes Ago', | ||
mode: 'simple', | ||
searchString: 'timestamp < TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 10 MINUTE)', | ||
for: ['database', 'api'], | ||
}, | ||
{ | ||
label: 'POST or PATCH', | ||
mode: 'custom', | ||
searchString: | ||
"REGEXP_CONTAINS(event_message, 'POST') OR REGEXP_CONTAINS(event_message, 'PATCH')", | ||
for: ['api'], | ||
}, | ||
{ | ||
label: 'Metadata IP', | ||
mode: 'custom', | ||
searchString: | ||
`SELECT timestamp, h.x_real_ip | ||
searchString: `SELECT timestamp, h.x_real_ip | ||
FROM edge_logs | ||
LEFT JOIN UNNEST(metadata) as m ON TRUE | ||
LEFT JOIN UNNEST(m.request) AS r ON TRUE | ||
LEFT JOIN UNNEST(r.headers) AS h ON TRUE | ||
WHERE h.x_real_ip IS NOT NULL | ||
`, | ||
for: ['database'], | ||
}, | ||
{ | ||
label: 'Requests by Country', | ||
mode: 'custom', | ||
searchString: `SELECT | ||
cf.country, count(*) as count | ||
FROM edge_logs | ||
LEFT JOIN UNNEST(metadata) as m ON TRUE | ||
LEFT JOIN UNNEST(m.request) AS r ON TRUE | ||
LEFT JOIN UNNEST(r.cf) AS cf ON TRUE | ||
GROUP BY | ||
cf.country | ||
ORDER BY | ||
DESC count | ||
`, | ||
for: ['api'], | ||
}, | ||
] | ||
|
||
export const DEFAULT_QUERY = 'SELECT timestamp, event_message FROM postgres_logs;' | ||
export const LOG_TYPE_LABEL_MAPPING: { [k: LogType]: string } = { | ||
api: 'API', | ||
database: 'Database', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters