Send log entries to postgres db
This commit is contained in:
parent
64fa7edc8e
commit
e5d612223b
10 changed files with 213 additions and 66 deletions
7
ingest/migrations/20220219194018_initial.down.sql
Normal file
7
ingest/migrations/20220219194018_initial.down.sql
Normal file
|
@ -0,0 +1,7 @@
|
|||
-- Add down migration script here
|
||||
DROP TABLE hits;
|
||||
DROP TABLE referrers;
|
||||
DROP TABLE user_agents;
|
||||
DROP TABLE remote_addresses;
|
||||
DROP TABLE hosts;
|
||||
DROP TABLE paths;
|
58
ingest/migrations/20220219194018_initial.up.sql
Normal file
58
ingest/migrations/20220219194018_initial.up.sql
Normal file
|
@ -0,0 +1,58 @@
|
|||
-- Location of the served file
|
||||
CREATE TABLE paths (
|
||||
-- The path string
|
||||
path text UNIQUE NOT NULL,
|
||||
-- The id of the path string
|
||||
id serial PRIMARY KEY NOT NULL
|
||||
);
|
||||
|
||||
-- Host header strings
|
||||
CREATE TABLE hosts (
|
||||
-- Host header value
|
||||
host text UNIQUE NOT NULL,
|
||||
-- The ID of the value
|
||||
id serial PRIMARY KEY NOT NULL
|
||||
);
|
||||
|
||||
-- Address for the requester
|
||||
CREATE TABLE remote_addresses (
|
||||
-- The IP address of the requester
|
||||
addr inet UNIQUE NOT NULL,
|
||||
-- The id of the address
|
||||
id serial PRIMARY KEY NOT NULL
|
||||
);
|
||||
|
||||
-- User agent strings
|
||||
CREATE TABLE user_agents (
|
||||
-- A User-Agent header value. Max length is the default maximum header size in nginx.
|
||||
agent varchar(8192) NOT NULL,
|
||||
-- The string's ID
|
||||
id serial PRIMARY KEY NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE referrers (
|
||||
-- A Referer header value. Max length is the default maximum header size in nginx.
|
||||
referrer varchar(8192) NOT NULL,
|
||||
-- The string's ID
|
||||
id serial PRIMARY KEY NOT NULL
|
||||
);
|
||||
|
||||
-- Requests
|
||||
CREATE TABLE hits (
|
||||
-- The size of the response payload
|
||||
size integer NOT NULL,
|
||||
-- Reference to a path id
|
||||
path serial NOT NULL REFERENCES paths (id),
|
||||
-- Reference to a remote host id
|
||||
remote serial NOT NULL REFERENCES remote_addresses (id),
|
||||
-- Reference to a host header id
|
||||
host serial NOT NULL REFERENCES hosts (id),
|
||||
-- Reference to a user agent
|
||||
user_agent serial NOT NULL REFERENCES user_agents (id),
|
||||
-- Reference to a referrer
|
||||
referrer serial NOT NULL REFERENCES referrers (id),
|
||||
-- Was the request served over HTTPS
|
||||
secure boolean NOT NULL,
|
||||
-- The time the request was made
|
||||
time timestamp with time zone NOT NULL
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue