This is a language/framework example project implementing the DevOps CMDB + Incident Knowledge Graph API described in ../spec/spec.md. It connects remotely to a Gremlin Server and does not use any embedded graph.
Key facts:
../spec/cmdb-data.gremlinQuick start (Gremlin Server via Docker):
docs/upgrade/java):chmod +x ./bin/gremlin-dev.sh./bin/gremlin-dev.sh up./bin/gremlin-dev.sh wait./bin/gremlin-dev.sh seed./bin/gremlin-dev.sh reset./bin/gremlin-dev.sh downTEMPORARY QUICK START STEPS ON STARTUP:
# connect to the running container after: ./bin/gremlin-dev.sh up` docker exec -it cmdb-gremlin /bin/bash # run the following in the container sed -i "s#org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer#org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer#" "conf/gremlin-server.yaml" exit # restart the container docker container restart cmdb-gremlin
The helper uses the Docker image tinkerpop/gremlin-server:3.7.4 and loads data by posting each line of ../spec/cmdb-data.gremlin to the Gremlin Server HTTP endpoint. No Gremlin Console is required.
Manual alternative (without the helper script):
docker run -d --name cmdb-gremlin -p 8182:8182 tinkerpop/gremlin-server:3.7.4curl -sS -H 'Content-Type: application/json' -X POST http://localhost:8182/gremlin --data '{"gremlin":"g.V().limit(1)"}'while IFS= read -r line; do \ [[ -z "$line" || "$line" =~ ^// || "$line" =~ ^# ]] && continue; \ json=$(printf '%s' "$line" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g'); \ curl -sS -H 'Content-Type: application/json' -X POST http://localhost:8182/gremlin --data "{\"gremlin\":\"$json\"}" >/dev/null; \ done < ../spec/cmdb-data.gremlin
Build & Run API:
mvn -q -f ./pom.xml clean packagemvn -q -f ./pom.xml mn:runmvn test -Dtest=ServiceITEndpoints (examples):
GET http://localhost:8080/health/readyGET http://localhost:8080/incidents/{incidentId}/blastRadius?depth=2GET http://localhost:8080/services/{serviceId}/dependencies?depth=2GET http://localhost:8080/services/{serviceId}/ownersGET http://localhost:8080/deployments/{deployId}/timelinePOST http://localhost:8080/alerts with JSON { "alertId": "a1", "source": "prom", "metric": "cpu", "firedAt": 1700000000000 }Configuration:
src/main/resources/application.yml for Gremlin connection settings.License: