Skip to content

Commit

Permalink
Adding seperate page on logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiehewitt15 committed Aug 14, 2024
1 parent 028d7bc commit 9584438
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Ocean Nodes run everything you need in the Ocean stack, they replace three previ

This is a minimal guide to quickly start and run an Ocean Node. See the [docs](/docs/) directory for more detailed information on Ocean Nodes and how to customise your setup.

**Note: this repository is currently excluded from all bug bounty programs.**

## Running Ocean Nodes in Docker (recommended)

Build and run the node using Docker:
Expand All @@ -19,7 +21,6 @@ Build and run the node using Docker:
### Prerequisites

- **Node Version:** Use the node version specified in `.nvmrc`.
- **Docker:** Ensure Docker is installed if you plan to run the node in a container.

### 1. Set Up Environment

Expand Down Expand Up @@ -90,4 +91,5 @@ For advanced testing scenarios, refer to the [Testing Guide](docs/testing.md).
- [Environmental Variables](docs/env.md)
- [Testing Guide](docs/testing.md)
- [Network Configuration](docs/networking.md)
- [COmpute to Data V2](docs/C2DV2.md)
- [Logging & accessing logs](docs/networking.md)
- [Compute to Data V2](docs/C2DV2.md)
102 changes: 102 additions & 0 deletions docs/Logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Logs

Refer to Logs section in the [environmental variables documentation](env.md#logs) for information on how to configure the logs.

## Log Retrieval using HTTP

### Get Multiple Logs

HTTP GET /logs

This endpoint retrieves multiple log entries based on various query parameters. If query parameters are not provided, it defaults to the last 24 hours of logs and a maximum of 100 log entries. Please replace the `startTime`, `endTime` values with actual data as per your requirement when making requests.

**Query Parameters:**

- `startTime` (optional): The start time for logs retrieval in ISO 8601 format.
- `endTime` (optional): The end time for logs retrieval in ISO 8601 format.
- `maxLogs` (optional): The maximum number of log entries to retrieve.
- `moduleName` (optional): The module name to filter the logs.
- `level` (optional): The log level to filter the logs (e.g., "info", "error").

**Example Request:**

```http
GET /logs?startTime=2023-01-01T00:00:00Z&endTime=2023-01-02T00:00:00Z&maxLogs=50&moduleName=auth&level=info
```

**Example Response:**

```json
[
{
"timestamp": 1700569124922,
"level": "info",
"message": "User logged in successfully.",
"moduleName": "HTTP"
},
{
"timestamp": 1700569124922,
"level": "info",
"message": "Session refreshed.",
"moduleName": "HTTP"
}
// More log entries...
]
```

If no logs are found for the given criteria, you will receive a `404 Not Found` response.

### Get a Single Log by ID

HTTP GET /log/:id

This endpoint retrieves a single log entry by its unique identifier.

**Path Parameters:**

- `id`: The unique identifier of the log entry.

Example Request:

```http
GET /log/123456789
```

```json
{
"id": "1",
"level": "info",
"message": "NEW Test log message 1700569124912",
"timestamp": 1700569124922,
"moduleName": "HTTP"
}
```

If the log with the given ID is not found, you will receive a `404 Not Found` response. For server errors, you will receive a `500 Internal Server Error` response.

## Log Retrieval Using Script

The logging system provides a convenient way to retrieve logs via a command-line script. The script is capable of fetching logs with various filters, such as start time, end time, maximum number of logs, module name, and log level.

**Usage**
You can call the script directly from your command line with optional parameters to filter the logs. The parameters are as follows:

- `API_URL`: The URL of the logs API endpoint. Defaults to http://localhost:8000.
- `START_TIME`: The start time for the logs you want to retrieve. Defaults to 24 hours before the current time.
- `END_TIME`: The end time for the logs you want to retrieve. Defaults to the current time.
- `MAX_LOGS`: The maximum number of logs to retrieve. Defaults to 100.
- `MODULE_NAME`: The specific module name to filter the logs. Optional.
- `LEVEL`: The specific log level to filter the logs. Optional.

**Example Without Parameters (Uses Defaults):**

```bash
npm run logs
```

**Example With Specific Parameters:**

```
npm run logs http://localhost:8000 "2023-11-01T00:00:00Z" "2023-11-30T23:59:59Z" 50 "http" "info"
```
3 changes: 3 additions & 0 deletions docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Environmental variables are also tracked in `ENVIRONMENT_VARIABLES` within `src/
- `RATE_DENY_LIST`: Blocked list of IPs and peer IDs. Example: `"{ \"peers\": [\"16Uiu2HAkuYfgjXoGcSSLSpRPD6XtUgV71t5RqmTmcqdbmrWY9MJo\"], \"ips\": [\"127.0.0.1\"] }"`
- `MAX_REQ_PER_SECOND`: Number of requests per second allowed by the same client. Example: `3`
- `MAX_CHECKSUM_LENGTH`: Define the maximum length for a file if checksum is required (Mb). Example: `10`

## Logs

- `LOG_LEVEL`: Define the default log level. Example: `debug`
- `LOG_CONSOLE`: Write logs to the console. Default is `false`, but becomes `true` if neither `LOG_FILES` or `LOG_DB` are set.
- `LOG_FILES`: Write logs to files. Default is `false`
Expand Down
Binary file modified docs/imgs/OceanNode-arhitecture.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9584438

Please sign in to comment.