Skip to content

cjhammons/nommer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nommer

API for ingesting events/logs/any data into a Mongo Database categorized by project.

Setup

You can clone this repo, or pull the docker image:

docker pull cjhammons/nommer:latest

You will need a .env file with your MongoDB URI and database, like this:

MONGO_URI=mongodb://<ip address>
MONGO_DATABASE=<database name>

Usage

To start sending data to the API, you'll first need to create a project via the POST /project endpoint. Then you can send data to this project via POST /{project_name}/event using the API key generated when the project is created.

Endpoints

POST /1/projects

Creates a project and returns an API key.

Example:

curl -X POST "http://localhost:8080/1/projects" \
     -H "Content-Type: application/json" \
     -d '{"name": "MyNewProject"}'

Be sure to write down the apikey!

POST /1/{project_name}/event

Sends an event to the project.

Example:

curl -X POST "http://localhost:8080/1/test_project/event" \
     -H "Content-Type: application/json" \
     -H "X-API-Key: your_actual_api_key_here" \
     #Note the data can take ANY form, as long as it is enclosed in the JSON Object called "event"
     -d '{"event": {"key1": "value1", "key2": "value2"}}'

GET /1/projects

Retrieves a list of all projects.

Example:

curl -X GET "http://localhost:8080/1/projects"

This will return a JSON array with the project details like project_id and project_name.

GET /1/{project_name}/event

Retrieves a list of all events for a specific project. Requires an API key in the header for authorization.

Example:

curl -X GET "http://localhost:8080/1/test_project/event" \
     -H "X-API-Key: your_actual_api_key_here"

This will return a JSON array containing all the events for the specified project.

Data Structure in MongoDB

Here is an example of how a project with a single event will appear in MongoDB:

{
  "_id": {
    "$oid": "650f49bcbad8d2c9a95ce18d"
  },
  "name": "test_project",
  "apikey": "abc123",
  "events": [
    {
      "timestamp": {
        "$date": "2023-09-23T20:26:28.573Z"
      },
      "Event": {
        "1": 2,
        "420": 69,
        "blah": "blerg",
        "bah bah black sheep": "Have you any wool?"
      }
    }
  ]
}

About

Data ingestion API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published