Skip to content

Commit a6a2ce5

Browse files
authored
Merge pull request #8 from KnowWhereGraph/metrics-endpoint
Add metrics endpoint
2 parents 604f290 + 7938d6a commit a6a2ce5

5 files changed

Lines changed: 503 additions & 496 deletions

File tree

README.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
API service for KnowWhereGraph
44

5-
## Running
6-
7-
To run the API in a production setting, deploy with docker
8-
1. `docker build -t kwg-api .`
9-
2. `docker run -d --name kwg-api -p 8080:8080 kwg-api`
10-
11-
Visit the redoc page at http://127.0.0.1:8080/redoc
12-
13-
Visit the swagger page at http://127.0.0.1:8080/docs
14-
155
## Features
166

177
- Node de-referencing
@@ -29,23 +19,6 @@ poetry run black .
2919
poetry run isort .
3020
```
3121

32-
### Running Locally
33-
34-
The API can be run locally when developing. To run,
35-
36-
```bash
37-
poetry install
38-
poetry run uvicorn kwg_api.main:app --reload --port 80
39-
```
40-
41-
#### Via Docker
42-
43-
The API can also be run using the `docker-compose.dev.yaml` file with
44-
45-
```commandline
46-
docker-compose -f docker-compose.local.yaml up
47-
```
48-
4922
### Testing
5023

5124
The unit tests can be run through pytest with
@@ -54,6 +27,7 @@ The unit tests can be run through pytest with
5427
poetry run pytest
5528
```
5629

30+
5731
## Building Docs
5832

5933
The API uses the sphinx documentation formation. To build the documentation, first [install sphinx](https://www.sphinx-doc.org/en/master/usage/installation.html).
@@ -64,3 +38,31 @@ Then,
6438
cd docs
6539
make build
6640
```
41+
42+
## Running
43+
44+
When the API is running, the following pages can be used to play with the endpoint
45+
46+
Visit the redoc page at http://127.0.0.1:8080/redoc
47+
48+
Visit the swagger page at http://127.0.0.1:8080/docs
49+
50+
51+
The API can be run locally when developing. To run,
52+
53+
### For local Development
54+
55+
#### Non-Docker
56+
57+
```bash
58+
poetry install
59+
poetry run uvicorn kwg_api.main:app --reload --port 80
60+
```
61+
62+
### With Docker
63+
64+
The API can also be run using the `docker-compose.dev.yaml` file with
65+
66+
```commandline
67+
docker-compose -f docker-compose.dev.yaml up
68+
```

docker-compose.dev.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3'
2+
3+
services:
4+
kwg-api:
5+
container_name: kwg-api
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
ports:
10+
- '8080:8080'
11+
environment:
12+
- base_address_http=http://staging.knowwheregraph.org
13+
- base_address_https=https://staging.knowwheregraph.org

kwg_api/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
import uvicorn
55
from fastapi import FastAPI, Request, Response
6+
from prometheus_fastapi_instrumentator import Instrumentator
67

78
from kwg_api.api.node_negotiator import NodeNegotiator
89
from kwg_api.lib.prefix_builder import PrefixBuilder
910

10-
app = FastAPI(title="KnowWhereGraph API", version="1.0.0")
1111
logging.basicConfig(level=logging.INFO)
12-
12+
app = FastAPI(title="KnowWhereGraph API", version="1.0.0")
13+
Instrumentator().instrument(app).expose(app)
1314

1415
@app.get(
1516
"/lod/ontology/{resource_id}",

0 commit comments

Comments
 (0)