Skip to content

Commit

Permalink
updates docs, thanks AustinW
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Updyke committed Oct 31, 2024
1 parent 330827d commit 2d3ac12
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 231 deletions.
48 changes: 18 additions & 30 deletions docs/core/api.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# Setting Up the GHOSTS API

???+ info "GHOSTS Source Code"
The [GHOSTS Source Code Repository](https://github.com/cmu-sei/GHOSTS) is hosted on GitHub.

*Updated on July 24, 2024*
_Updated on October 30, 2024_

The GHOSTS API enables the control and orchestration of non-player characters (NPCs) within a deployment. It supports logging, reporting, and managing individual, groups of, or entire deployments of client installs.

The GHOSTS API consists of three components: the API itself for configuring and managing characters and machines, a Postgres database for managing all the pieces, and Grafana for seeing GHOSTS activities in one convenient dashboard. Each of these three components runs in its own docker container.

Steps to set up the GHOSTS API:

1. Choose where to host the API
2. Install Docker and Docker Compose
3. Build the GHOSTS containers
4. Test the API
1. Choose where to host the API
2. Install Docker and Docker Compose
3. Build the GHOSTS containers
4. Test the API

## Step 1 — Choose Where to Host the API

Expand Down Expand Up @@ -42,62 +39,53 @@ Once you have confirmed that Docker and Docker Compose are installed, you can bu

Create a directory where you want to store the build files and containers.

```
$ mkdir ghosts-project
$ cd ghosts-project
```shell
mkdir ghosts-project
cd ghosts-project
```

Download the docker compose file for GHOSTS.

```
$ curl https://raw.githubusercontent.com/cmu-sei/GHOSTS/master/src/Ghosts.Api/docker-compose.yml -o docker-compose.yml
```shell
curl https://raw.githubusercontent.com/cmu-sei/GHOSTS/master/src/Ghosts.Api/docker-compose.yml -o docker-compose.yml
```

Build all of the containers at once using docker-compose.

```
$ docker-compose up -d
docker-compose up -d
```

Check for the running containers.

```
$ docker ps -a
docker ps -a
```

If everything succeeds you should see the three new containers for the API, Grafana, and Postgres.
If everything succeeds you should see four new containers for the API, UI, Grafana, and Postgres.

![Running Containers](../../images/api/installing-the-api-running-containers.png)
![Running Containers](../images/installing-the-api-running-containers.png)

## Step 4 — Testing the API

By default, the API is hosted on port 5000. You should be able to reach the API from [http://localhost:5000](http://localhost:5000). If you open this page in your browser, you should see the initial API page outlining the version of the install, and a few test machine entries. If this page renders, your API is up, running, and available.

![Success!](../../images/api/installing-the-api-success.png)
![Success!](../images/installing-the-api-success.png)

## Troubleshooting

### Problem: The API home page has an error

![API Home Page Error](../../images/api/installing-the-api-error.png)
![API Home Page Error](../images/installing-the-api-error.png)

Answer: Make sure the docker container for Postgres is running using Docker Desktop or the command `docker ps -a`

![Running Containers](../../images/api/installing-the-api-running-containers.png)
![Running Containers](../images/installing-the-api-running-containers.png)

You can check the logs with the command `docker logs ghosts-postgres` to look for container errors.

### Problem: The social graph link has an error

![API Social Graph Page Error](../../images/api/installing-the-api-social-error.png)
![API Social Graph Page Error](../images/installing-the-api-social-error.png)

Answer: You haven't created a social network yet, this is normal.

### Problem: Is the API up and running?

- Go to `/api/home` in the browser, it should return the current API version and the number of machines and groups under management. If it says relationship not found, restart the API application and it should create the database automatically.
- Run `docker ps --all` and see that all containers are running normally. If one or more is not running, look at the logs for that machine via `docker logs [machine name]`.

> The ClientId, ClientResults, and other Client* endpoints are failing.
The Client* endpoints are for the Clients to use only. There are specific header values set by the client in the request that is used to authenticate the request. If you are not using the client, you will not have these headers set, and these endpoints will fail.
53 changes: 28 additions & 25 deletions docs/core/grafana.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Configuring Grafana

*Updated on July 25, 2024*
_Updated on October 30, 2024_

[Grafana](https://grafana.com/) for GHOSTS allows the simulation administrator to visualize all activities carried out by the NPCs across the simulation in dashboard with pretty colors and charts.
[Grafana](https://grafana.com/) for GHOSTS allows the simulation administrator to visualize all activities carried out by the NPCs across the simulation in dashboard with pretty colors and charts.

## Prerequisites

- Your GHOSTS API should be installed and running (see [Setting Up the GHOSTS API](installing-the-api.md))
- Your GHOSTS API should be installed and running (see [Setting Up the GHOSTS API](installing-the-api.md))

## Step 1 — Container Set Up

Expand All @@ -15,26 +15,26 @@ The Grafana docker container will be installed during the process of [Setting Up
You can check its status with the docker command

```
$ docker ps -a
docker ps -a
```

If the container is continuously restarting, Grafana does not have the permissions it needs.

![Grafana Restarting](../../images/grafana/configuring-grafana-restarting.png)
![Grafana Restarting](../images/configuring-grafana-restarting.png)

You can also check the docker logs:

```
$ docker logs ghosts-grafana
docker logs ghosts-grafana
```

![Grafana Permission Denied](../../images/grafana/configuring-grafana-permission-denied.png)
![Grafana Permission Denied](../images/configuring-grafana-permission-denied.png)

If you don't see this issue, you can continue to Step 2. If you do see this issue you will need to grant permissions on the `_g` directory of the ghosts-api folder (which stores the Grafana data for the GHOSTS API).

```
$ cd ghosts-api
$ chmod 777 _g
```shell
cd ghosts-api
chmod 777 _g
```

Ensure the container is running with `docker ps`.
Expand All @@ -43,7 +43,7 @@ Ensure the container is running with `docker ps`.

Once the container is running you can access its front end by default at [localhost:3000](http://localhost:3000)

![Grafana Front end](../../images/grafana/configuring-grafana-front-end.png)
![Grafana Front end](../images/configuring-grafana-front-end.png)

The default login is:

Expand All @@ -57,41 +57,44 @@ Continue through the setup prompts.

Now you need to tell Grafana where it will be getting its data.

1. Open the "Connections" from the left menu.
2. Click on "Add new data source" in the top right corner
1. From the "Connections" drop down menu on the left side, choose the "Data Sources" option
2. Click the "Add new data source" button
3. Search for "Postgres" and choose the PostgreSQL option
4. Name the datasource "ghosts" and leave it as the default
5. Under the "Connection" section of the config, set
- host url to "ghosts-postgres:5432"
- database name to "ghosts"

- host url to "ghosts-postgres:5432"
- database name to "ghosts"

6. Under the "Authentication" section of the config, set
- username to "ghosts"
- password to "scotty@1"
- TLS/SSL Mode to "disable"
7. Leave everything else at its default and click the "Save and test" button at the bottom of the page

- username to "ghosts"
- password to "scotty@1"
- TLS/SSL Mode to "disable"

7. Leave everything else at its default and click the "Save and test" button at the bottom of the page

### Step 4 — Choosing a Dashboard

Grafana dashboards are very flexible and can be configured to show any statistics that are important to your simulation or experiment.

GHOSTS comes with some premade dashboards to get you started. You can download those here: https://github.com/cmu-sei/GHOSTS/tree/master/configuration/grafana/dashboards

- GHOSTS-5-default Grafana dashboard — shows status across all machines
- GHOSTS-5-group-default Grafana dashboard — shows status with machines grouped by enclave
- GHOSTS-5-default Grafana dashboard — shows status across all machines
- GHOSTS-5-group-default Grafana dashboard — shows status with machines grouped by enclave

#### Loading an existing dashboard

Navigate to "Dashboards" in the left menu. There will be a blue "New" button in the top right corner.

![Empty Dashboard](../../images/grafana/configuring-grafana-empty-dashboard.png)
![Empty Dashboard](../images/configuring-grafana-empty-dashboard.png)

Click "New". Then, "import".
Click "New". Then, "import".

You can either upload one of the dashboard json files from the GHOSTS repository or simply copy and paste the json into the "import via dashboard json model" panel.
You can either upload one of the dashboard json files from the [GHOSTS repository](https://github.com/cmu-sei/GHOSTS/tree/master/configuration/grafana/dashboards) or simply copy and paste the json into the "import via dashboard json model" panel.

Choose the ghosts datasource you added earlier from the drop down menu and then click "import".

![Ghosts In the Dashboard](../../images/grafana/configuring-grafana-dashboard.png)
![Ghosts In the Dashboard](../images/configuring-grafana-dashboard.png)

You are now set up with Grafana!
Binary file added docs/images/configuring-grafana-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/configuring-grafana-front-end.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/configuring-grafana-restarting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/installing-the-api-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/installing-the-api-social-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/installing-the-api-success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/setting-up-shadows-services-on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2d3ac12

Please sign in to comment.