A node/express web app for handling REST requests for OpenNMS usage statistics and user data.
- Make sure that node.js is installed on the system
- Currently should use npm version 10 or higher; node version 18 or higher
- Change to the project folder and run the following command
npm install- Start elastic search docker container first (don't need this if you are only testing the
user-data-collectionfeature)
docker run -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.6.2- Run the following command to compile the code and start the server
npm start- Run Usage Stats Handler, Elasticsearch and Grafana
docker-compose up --build --abort-on-container-exit --remove-orphans --force-recreate- Note: At times elasticsearch hangs on startup, to fix this either run it again and/or run
docker system prune- Running
test/opennms-test.httpin Intellij to test or using the curl to post report - Using the following command to verify the report saved
curl -v -X POST --location "http://localhost:9200/opennms_log/_count?pretty"
curl -v -X POST --location "http://localhost:9200/opennms_system/_count?pretty"- Visualise the grafana graph update with new values on a refresh
Add a file config/production.json which is a copy of config/default.json but with actual production values populated.
- Note: make sure not to check in
config/production.jsonas it may contain credentials.
Then:
npm run start:prodIf you are running this in a different way (e.g. as part of a service), you can run npm build-only to build. Make sure to set the NODE_ENV environment variable to production (export NODE_ENV=production), and also set NODE_CONFIG_DIR to the config directory, then run the dist/app.js file:
export NODE_ENV=production
export NODE_CONFIG_DIR=/opt/usage-stats-handler/config
node dist/app.jsGET /Base URL, but there's actually nothing at that path, it will return a 404GET /pingGet a basic ping responsePOST /usage-reportSend an OpenNMS Horizon usage reportPOST /hs-usage-reportSend an OpenNMS Horizon Stream usage reportPOST /user-data-collectionSubmit user data collection data