Skip to content

Commit

Permalink
Merge pull request #12 from alexcreasy/grafana
Browse files Browse the repository at this point in the history
Add grafana integration for chart display (#11)
  • Loading branch information
alexcreasy authored Sep 20, 2023
2 parents fe7a31c + 9e830e2 commit 0d86f27
Show file tree
Hide file tree
Showing 34 changed files with 232,323 additions and 25 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ COPY --from=build-stage /usr/src/app/dist/ /opt/app-root/src
COPY --from=build-stage /usr/src/app/nginx.conf "$NGINX_CONF_PATH"

ENV TRUSTYAI_URL="http://trustyai-service:8080"
ENV GRAFANA_URL="http://grafana:3000"


CMD ["nginx", "-g", "daemon off;"]

Expand Down
72 changes: 56 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,40 @@
Web console for TrustyAI Explainability Service.

## Running the container
Set the address of the TrustyAI service by setting the environment variable `TRUSTYAI_URL` as below:
Set the address of the TrustyAI and Grafana services by setting the environment variables `TRUSTYAI_URL` and `GRAFANA_URL` as below:

```shell
docker run --rm -p 8989:8989 -e TRUSTYAI_URL=http://localhost:8080 trustyai-console
docker run --rm -p 8081:8080 -e TRUSTYAI_URL=http://localhost:8080 -e GRAFANA_URL=http://grafana:3000 trustyai-console
```

The console will then be available at: http://localhost:8989

### Docker compose example
```shell
services:
console:
image: trustyai-console
container_name: console
ports:
- "8989:8989"
environment:
TRUSTYAI_URL: "http://trustyai:8080"
trustyai:
image: trustyai/trustyai-service:999-SNAPSHOT
image: quay.io/rgeada/trustyai-service:grafana-demo
container_name: trustyai-service
ports:
- "8080:8080"
environment:
SERVICE_KSERVE_TARGET: "localhost"
SERVICE_STORAGE_FORMAT: "MEMORY"
SERVICE_DATA_FORMAT: "CSV"
SERVICE_METRICS_SCHEDULE: "5s"
SERVICE_BATCH_SIZE: 5000
STORAGE_DATA_FILENAME: "data.csv"
STORAGE_DATA_FOLDER: "/inputs"
LOG_LEVEL: "DEBUG"
volumes:
- ~/volumes/pvc/inputs:/inputs
trustyai-console:
image: quay.io/acreasy/trustyai-console:grafana
container_name: trustyai-console
ports:
- 8081:8080
environment:
TRUSTYAI_URL: http://trustyai:8080
GRAFANA_URL: http://grafana:3000
prometheus:
image: prom/prometheus
container_name: prometheus
Expand All @@ -46,19 +47,58 @@ services:
volumes:
- ./prometheus:/etc/prometheus
- prom_data:/prometheus
generator:
container_name: generator
image: trustyai/trustyai-service-generator
grafana:
image: grafana/grafana
container_name: grafana
ports:
- 3000:3000
restart: unless-stopped
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: admin
GF_AUTH_ANONYMOUS_ENABLED: true
GF_SECURITY_ALLOW_EMBEDDING: true
GF_SERVER_ROOT_URL: http://trustyai-console:8080/grafana/
GF_SERVER_SERVE_FROM_SUB_PATH: true
volumes:
- ./grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml
- ./grafana/dashboard.yaml:/etc/grafana/provisioning/dashboards/main.yaml
- ./grafana/dashboards:/var/lib/grafana/dashboards
generator-1:
container_name: generator-1
image: trustyai/trustyai-service-partial
build:
context: ./logger
dockerfile: ./generator.Dockerfile
dockerfile: ./partial.Dockerfile
environment:
MODEL_NAME: "example-model-1"
SERVICE_ENDPOINT: "http://trustyai:8080/consumer/kserve/v2/full"
SERVICE_ENDPOINT: "http://trustyai:8080/consumer/kserve/v2"
PYTHONUNBUFFERED: "1"
generator-2:
container_name: generator-2
image: trustyai/trustyai-service-partial
build:
context: ./logger
dockerfile: ./partial.Dockerfile
environment:
MODEL_NAME: "example-model-2"
SERVICE_ENDPOINT: "http://trustyai:8080/consumer/kserve/v2"
PYTHONUNBUFFERED: "1"

volumes:
prom_data:
```

Run `docker compose up -d` and open the console at: http://localhost:8989

### Running the demo

From the demo directory run:

```shell
docker compose build
docker compose up -d
./add-requests.sh
```

Open a browser and point it at `http://localhost:8081`
62 changes: 62 additions & 0 deletions demo/add-requests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

curl -X POST --location "http://localhost:8080/metrics/spd/request" \
-H "Content-Type: application/json" \
-d "{
\"modelId\": \"example-model-1\",
\"requestName\": \"SPD Input-2 Low\",
\"protectedAttribute\": \"input-2\",
\"favorableOutcome\": 0.0,
\"outcomeName\": \"input-0\",
\"privilegedAttribute\": 1.0,
\"unprivilegedAttribute\": 0.0
}"

curl -X POST --location "http://localhost:8080/metrics/spd/request" \
-H "Content-Type: application/json" \
-d "{
\"modelId\": \"example-model-1\",
\"requestName\": \"SPD Input-1 Low\",
\"protectedAttribute\": \"input-1\",
\"favorableOutcome\": 0.0,
\"outcomeName\": \"input-0\",
\"privilegedAttribute\": 1.0,
\"unprivilegedAttribute\": 0.0
}"

curl -X POST --location "http://localhost:8080/metrics/dir/request" \
-H "Content-Type: application/json" \
-d "{
\"modelId\": \"example-model-1\",
\"requestName\": \"DIR Input-1 Low\",
\"protectedAttribute\": \"input-1\",
\"favorableOutcome\": 0.0,
\"outcomeName\": \"input-0\",
\"privilegedAttribute\": 1.0,
\"unprivilegedAttribute\": 0.0
}"


curl -X POST --location "http://localhost:8080/metrics/spd/request" \
-H "Content-Type: application/json" \
-d "{
\"modelId\": \"example-model-2\",
\"requestName\": \"M2 SPD Input-2 High\",
\"protectedAttribute\": \"input-2\",
\"favorableOutcome\": 1.0,
\"outcomeName\": \"input-0\",
\"privilegedAttribute\": 1.0,
\"unprivilegedAttribute\": 0.0
}"

curl -X POST --location "http://localhost:8080/metrics/dir/request" \
-H "Content-Type: application/json" \
-d "{
\"modelId\": \"example-model-2\",
\"requestName\": \"M2 DIR Input-1 High\",
\"protectedAttribute\": \"input-1\",
\"favorableOutcome\": 1.0,
\"outcomeName\": \"input-0\",
\"privilegedAttribute\": 1.0,
\"unprivilegedAttribute\": 0.0
}"
Loading

0 comments on commit 0d86f27

Please sign in to comment.