This is the official logging service by snek-at.
Featuring the fully functional prototype and the set-up guide.
Report bug
·
Request feature
·
Documentation
- 🚀 Get Up and Running in 5 Minutes
- 🖨️ Generating Logs
- 🐞 How to Report a Bug or Request a Feature
- 🤝 How to Contribute
- 💚 Thanks
- 💼 Creators
- 🤔 FAQs
- 📝 Copyright and License
This chapter desribes how to set up your personal logging prototype, which can also be modified to use as a personal logging service.
The first step is to clone the code, to do this just us the following command.
git clone https://github.com/schett-net/snek-log-prototype.git
After successfully cloning the repository, the next step is to install the required packages.
The first requirements that have to be installed are the ones of the function. To do this move into the functions directory and run the following command.
cd functions;
yarn
The functions directory needs another installation inside the src folder, because the python packages cannot be installed in compination with the node packages. To install the python dependencies move into the correct directory and run the following command.
cd src/log_prototype/;
python setup.py install
The last step is to move into the directory of the demo website and install the requirements using following command.
cd ../../../website;
yarn
The next step is to move into the factory.ts
file and set your personal url that the Graphql service is going to run on. You also have to make sure that this url is publically accessable otherwise the service will not work.
export const fn = makeFn({
url: "https://your-url/graphql",
});
Now that all services are ready they can be started one by one, each service needs a seperate terminal to be started in.
Start of by starting the proxy handler, the proxy handler is started first because the functions and the website service require the functionallity of storing logs into parquet files. The proxy handler is started with the following command.
cd functions/src/log_prototype/;
python3 -m log_prototype.proxy_handler
The proxy handler is now running, open a new terminal and keep it running in background. In the new terminal the function service will be started, to do this enter the following command inside the functions directory.
cd functions;
yarn start
The Grahpql server should now be up and running make sure it has the same url as configured in the settings and that is publically accessible. If thats the case the last step is to open another terminal and start the website using the following command.
cd website;
yarn start
🎉 Congrats you have successfully set up the logging service.
This chapter describes the possibillities to generate logs using the prototype.
Graphql is the fastet way to generate hand written logs, just open the Graphql web-service that has been previously started and send a log like this example.
mutation log {
log (fnArgs: {
agent: "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1",
bytes: 732,
clientip: "21.238.71.24",
geo: {
coordinates: {
lat: 36.29441667,
lon: -95.47966667
},
dest: "JP",
src: "ID",
srcdest: "ID:JP"
},
host: "www.elastic.co",
ip: "31.238.71.24",
machine: {
os: "ios",
ram: 9663676416
},
message: "31.238.71.24 - - [2018-07-25T07:41:11.237Z] \"GET / HTTP/1.1\" 200 732 \"-\" \"Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1\"",
referer: "http://twitter.com/success/sergey-volkov",
request: "/",
response: 200,
timestamp: "2022-07-13T07:41:11.237Z",
url: "https://www.elastic.co/products",
tags: {
list: ["success", "info"]
}
fingerprint: "ce1e9723c10e498b37a328a92c58f71b",
})
}
The second and more common way to generate logs is to implement the function into an running web service. This can be done by importing the log functionallity into the wanted page like this.
import log from "../../../functions/src/log";
After importing it, the function can be used like the Graphql mutation, just pass some parameters that should be logged and the function is going to store it into the parquet file. In our example we also tried to attach some dynamic data like a fingerprint to store more than just static data all the time.
const fpPromise = FingerprintJS.load({
monitoring: false
});
const fp = await fpPromise;
const result = await fp.get();
var str = new Date().setSeconds(0,0);
var dt = new Date(str).toISOString();
// The static data should be replaced with real data server sided
await log({
"fingerprint": result.visitorId,
"agent": "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1",
"bytes": 732,
"clientip": "21.238.71.24",
"geo": {
"coordinates": {
"lat": 36.29441667,
"lon": -95.47966667
},
"dest": "JP",
"src": "ID",
"srcdest": "ID:JP"
},
"host": location.host,
"ip": "31.238.71.24",
"machine": {
"os": result.components.osCpu.value,
"ram": 9663676416
},
"message": errorInfo.componentStack,
"referer": "http://twitter.com/success/sergey-volkov",
"request": "/",
"response": 200,
"tags": {
"list": [ error ]
},
"timestamp": dt,
"url": location.toString()
});
The full example of the implementation can be found here.
Have a bug or a feature request? Please first search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.
Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.
All code should conform to the Code Guide, maintained by snek-at.
We do not have any external contributors yet, but if you want your name to be here, feel free to contribute to our project.
|
|
|
Nico Schett | Florian Kleber | David Pinterics |
Use of this source code is governed by an EUPL-1.2 license that can be found in the LICENSE file at https://snek.at/license