Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ aliases = ["/contribute"]
</div>
<div class="item">
<div class="icon"><i class="lni lni-cloud" aria-hidden="true"></i></div>
<a href="https://dgraph.io/docs/cloud/">
<a href="{{< relref "/dgraphcloud">}}">
<h2>Dgraph Cloud</h2>
<p>
Run Dgraph in the Cloud.
Expand Down
71 changes: 45 additions & 26 deletions content/dgraphcloud/_index.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,74 @@
+++
title = "Dgraph Cloud"
[menu.main]
identifier = "dgraphcloud"
identifier = "cloud"
weight = 9
+++

<div class="landing">
<div class="hero">
<h1></h1>
<p>
This section is about Dgraph Cloud.
Dgraph Cloud gives you the power of Dgraph database with the convenience of a fully-managed service.
</p>
<img class="hero-deco" src="/images/hero-deco_403x160.png" />
<p>To learn more about Dgraph, see <a href="{{< relref "dgraph-overview.md">}}">Dgraph Database Overview</a>.</p>
<img class="hero-deco" src="images/hero-deco.png" />
</div>
<div class="item">
<div class="icon"><i class="lni lni-download" aria-hidden="true"></i></div>
<a href="{{< relref "/installation/download.md">}}">
<h2>Download</h2>
<div class="icon"><i class="lni lni-play" aria-hidden="true"></i></div>
<a href="{{< relref "cloud-quick-start.md">}}">
<h2>Dgraph Cloud Quick Start</h2>
<p>
Download the images and source files to build and install for a production-ready Dgraph cluster
Get started with a simple "to-do" list app built on Dgraph Cloud
</p>
</a>
</div>
<div class="item">
<div class="icon"><i class="lni lni-docker" aria-hidden="true"></i></div>
<a href="{{< relref "/installation/kubernetes.md">}}">
<h2>Using Kubernetes</h2>
<div class="icon"><i class="lni lni-rocket" aria-hidden="true"></i></div>
<a href="{{< relref "advanced-queries.md">}}">
<h2>Advanced Queries with DQL</h2>
<p>
Running Dgraph with Kubernetes
Generate advanced queries to interact with your database using the HTTP or gRPC endpoint
</p>
</a>
</div>
<div class="item">
<div class="icon"><i class="lni lni-package" aria-hidden="true"></i></div>
<a href="{{< relref "cloud-api/overview.md">}}">
<h2>Dgraph Cloud API</h2>
<p>
Programmatically launch and manage your Cloud backups.
</p>
</a>
</div>

<style>
ul.contents {
display: none;
}
</style>


<div class="item">
<div class="icon"><i class="lni lni-cog" aria-hidden="true"></i></div>
<a href="{{< relref "../installation/single-host-setup.md">}}">
<h2>Single Host Setup</h2>
<div class="icon"><i class="lni lni-shield" aria-hidden="true"></i></div>
<a href="{{< relref "security.md">}}">
<h2>Secure Your Endpoint</h2>
<p>
Setting up Dgraph on a single host
Tips for securing your Dgraph Cloud backend
</p>
</a>
</div>
<div class="item">
<div class="icon"><i class="lni lni-cogs" aria-hidden="true"></i></div>
<a href="{{< relref "../installation/multi-host-setup.md">}}">
<h2>Multi Host Setup</h2>
<a href="{{< relref "migrating-from-hosted-dgraph.md">}}">
<h2>Migrate from Self-Managed Dgraph</h2>
<p>
Setting up Dgraph on multiple hosts
Easily migrate your app's existing Dgraph backend to Dgraph Cloud
</p>
</a>

</div>
<div class="item">
<div class="icon"><i class="lni lni-control-panel" aria-hidden="true"></i></div>
<a href="{{< relref "admin/_index.md">}}">
<h2>Administer Your Backend</h2>
<p>
Programmatically set and update your schema, import or export your data, and switch or clone your Dgraph Cloud backend
</p>
</a>
</div>

</div>

Expand All @@ -64,3 +77,9 @@ title = "Dgraph Cloud"
display: none;
}
</style>

You might also be interested in:

- [Dgraph GraphQL Schema Reference](https://dgraph.io/docs/graphql/schema/schema-overview), which lists all the types and directives supported by Dgraph
- [Dgraph GraphQL API Reference](https://dgraph.io/docs/graphql/api/api-overview), which serves as a guide to using your new `/graphql` endpoint

7 changes: 7 additions & 0 deletions content/dgraphcloud/admin/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
+++
title = "Administering Your Backend"
weight = 15
[menu.main]
identifier = "cloud-admin"
parent = "cloud"
+++
31 changes: 31 additions & 0 deletions content/dgraphcloud/admin/authentication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
+++
title = "Authentication"
weight = 2
[menu.main]
parent = "cloud-admin"
+++

Administrating your Dgraph Cloud using the `/query`, `/mutate`, `/commit`, `/admin`, `/admin/slash`, or `/alter` endpoints on Dgraph Cloud. Also, bypassing Anonymous Access restrictions on the `/graphql` endpoint requires an API key. You can generate a new API key from Dgraph Cloud by selecting the ["Settings" button](https://cloud.dgraph.io/_/settings) from the sidebar, and then clicking the **Add API Key** button. Keep your API key safe, it will not be accessible once you leave the page.

![Dgraph Cloud: Add an API Key](/images/cloud-4.png)

There are two types of API keys: *client* and *admin*.

- **Client API keys** can only be used to perform query, mutation, and commit operations.
- **Admin API keys** can be used to perform both client operations and admin operations like drop data, destroy backend, and update schema.

{{% notice "note" %}}
Either Client API keys or Admin API keys can be used to bypass [Anonymous Access](/security) restrictions.
{{% /notice %}}

![Dgraph Cloud: Select API Key Role](/images/cloud-5.png)
<br>
<br>
All admin API requests must be authenticated by passing the API key as the 'Dg-Auth' header to every HTTP request. You can verify that your API key works by using the following HTTP example.

```
curl 'https://<your-backend>/admin' \
-H 'Dg-Auth: <your-api-key>' \
-H 'Content-Type: application/json' \
--data-binary '{"query":"{ getGQLSchema { schema } }"}'
```
12 changes: 12 additions & 0 deletions content/dgraphcloud/admin/clone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
+++
title = "Cloning Backend"
weight = 7
[menu.main]
parent = "cloud-admin"
+++

Cloning a backend allows making a copy of an existing backend. The clone will be created with all the data and schema of the original backend present at the time of cloning. The clone will have its own endpoint and will be independent of the original backend once it is created. Any further changes in either backends will not reflect in the other. Currently, a clone can only be created in the same zone as that of the original backend.

In order to clone your backend, click on the <kbd>Clone Backend</kbd> button under the [Settings](https://cloud.dgraph.io/_/settings) tab in the dashboard's sidebar.

You can also perform the restore operation on an existing backend if you have an unused backend or want to reuse an existing endpoint. But note that the restore operation will drop all the existing data along with schema on the current backend and replace it with the original backend's data and schema.
36 changes: 36 additions & 0 deletions content/dgraphcloud/admin/drop-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
+++
title = "Dropping Data from your Backend"
weight = 5
[menu.main]
parent = "cloud-admin"
+++

It is possible to drop all data from your Dgraph Cloud backend, and start afresh while retaining the same endpoint. Be careful, as this operation is not reversible, and all data will be lost. It is highly recommended that you [export](/admin/import-export) your data before you drop your data.

In order to drop all data while retaining the schema, click the <kbd>Drop Data</kbd> button under the [Schema](https://cloud.dgraph.io/_/schema) tab in the sidebar.

![Drop Data](/images/drop-data.png)

### Dropping Data Programmatically

In order to do this, call the `dropData` mutation on `/admin/slash`. As an example, if your GraphQL endpoint is `https://frozen-mango.us-west-2.aws.cloud.dgraph.io/graphql`, then the admin endpoint for schema will be at `https://frozen-mango.us-west-2.aws.cloud.dgraph.io/admin/slash`.

Please note that this endpoint requires [Authentication](/admin/authentication).

Please see the following curl as an example.

```
curl 'https://<your-backend>/admin/slash' \
-H 'X-Auth-Token: <your-token>' \
-H 'Content-Type: application/graphql' \
--data-binary 'mutation { dropData(allData: true) { response { code message } } }'
```

If you would like to drop the schema along with the data, then you can set the `allDataAndSchema` flag.

```
curl 'https://<your-backend>/admin/slash' \
-H 'X-Auth-Token: <your-token>' \
-H 'Content-Type: application/graphql' \
--data-binary 'mutation { dropData(allDataAndSchema: true) { response { code message } } }'
```
156 changes: 156 additions & 0 deletions content/dgraphcloud/admin/import-export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
+++
title = "Importing and Exporting data from Dgraph Cloud"
weight = 4
[menu.main]
parent = "cloud-admin"
+++

You can export your data from one Dgraph Cloud backend, and then import this data back into another Dgraph instance or Dgraph Cloud Backend.

## Exporting Data

You can export your data using JSON format. To do this, call the `export` mutation on `/admin/slash`. As an example, if your GraphQL endpoint is at `https://frozen-mango.us-west-2.aws.cloud.dgraph.io/graphql`, then the `/admin` endpoint for the schema is at `https://frozen-mango.us-west-2.aws.cloud.dgraph.io/admin/slash`.

{{% notice "note" %}}
The `/admin/slash` endpoint requires [Authentication](/admin/authentication).
{{% /notice %}}

The following is an example of a GraphQL mutation to export data to JSON.

```graphql
mutation {
export {
response { code message }
exportId
taskId
}
}
```
Make sure to keep your `exportId` and `taskId` safe as you will need them for getting the signed URLs in order to download your export files. These URLs will be returned in the `signedUrls` output field and **they expire after 48 hours**.

Export will usually return 3 files:
* `g01.gql_schema.gz`: The GraphQL schema file. This file can be re-imported via the [Schema APIs](/admin/schema)
* `g01.json.gz`: the data from your instance, which can be imported via live loader
* `g01.schema.gz`: This file is the internal Dgraph schema. If you have set up your backend with a GraphQL schema, then you should be able to ignore this file.

The following is an example of GraphQL query to check the status of the export and get the signed URLs for downloanding your export files.

```graphql
query {
exportStatus (
exportId:"<paste-your-exportId>"
taskId: "<paste-your-taskId>"
){
kind
lastUpdated
signedUrls
status
}
}
```
## Exporting Data with Multi-Tenancy feature enabled

{{% notice "note" %}}
With Multi-Tenancy feature enabled, for any GraphQL request you will need to provide the `accessJWT` for the specific user in the `X-Dgraph-AccessToken` header.
{{% /notice %}}

You can trigger two types of exports:
* cluster-wide export: this is an export of the entire backend (including all namespaces). This request can be only triggered by the [*Guardian of Galaxy*](https://dgraph.io/docs/enterprise-features/multitenancy/#guardians-of-the-galaxy) users.
* namespace-specific export: this is an export of a specific namespace. This request can be triggered by the *Guardian of Galaxy* users and by the *Guardian of Namespace* users.

### Cluster-wide Exports

This can only be done by the *Guardian of Galaxy* users (AKA Super Admin), the steps are:

1. Get the `accessJWT` token for the *Guardian of Galaxy* user. Send the following GraphQL mutation to the `/admin` endpoint:
```graphql
mutation login($userId: String, $password: String, $namespace: Int) {
login(userId: $userId, password: $password, namespace: $namespace) {
response {
accessJWT
refreshJWT
}
}
}
```
Your variables should be referring to the *Guardian of Galaxy* user:
```json
{
"userId": "groot",
"password": "password",
"namespace": 0
}
```
2. Once obtained the `accessJWT` token you need to pass it in `X-Dgraph-AccessToken` Header and only then you can send the following GraphQL mutation to `/admin/slash` endpoint:
```graphql
mutation {
export (namespace: -1) {
response { code message }
exportId
taskId
}
}
```
3. Once done, you can now send the following GraqhQL mutation to get the `signedUrls` from where you can download your export files:
```graphql
query {
exportStatus (
exportId:"<paste-your-exportId>"
taskId: "<paste-your-taskId>"
){
kind
lastUpdated
signedUrls
status
}
}
```

### Namespace-specific Exports

Namespace-specific exports can be triggered by the *Guardian of Galaxy* users. In this case you can follow the same steps for the cluster-wide exports and replace the namespace value from `-1` to the namespace you want to export. It's important that you get the `accessJWT` token for the *Guardian of Galaxy* user and pass it in the `X-Dgraph-AccessToken` header.

E.g. if you want to export the namespace `0x123` your GraphQL request sent to the `/admin/slash` endpoint would look like:
```graphql
mutation {
export (namespace: 123) {
response { code message }
exportId
taskId
}
}
```
You can also trigger namespace-specific export using the *Guardian of Namespace* users, in this case there is no need to specify any namespace in the GraphQL request as these users can only export their own namespace. It's important that you get the `accessJWT` token for the *Guardian of Namespace* user and pass it in the `X-Dgraph-AccessToken` header.

The GraphQL request sent to the `/admin/slash` endpoint would be:
```graphql
mutation {
export {
response { code message }
exportId
taskId
}
}
```

## Importing data with Live Loader

It is possible to import data into a Dgraph Cloud backend using [live loader](https://dgraph.io/docs/deploy/#live-loader). In order to import data, do the following steps:

1. First import your schema into your Dgraph Cloud backend, using either the [Schema API](/admin/schema) or via [the Schema Page](https://cloud.dgraph.io/_/schema).
2. Log into Dgraph Cloud, and find your backend's `gRPC Endpoint` on the Settings page. This will look like `frozen-mango.grpc.us-west-1.aws.cloud.dgraph.io:443`

{{% notice "note" %}}
The gRPC endpoint URL must have the string `.grpc.` added after the domain prefix. Without this change, Live Loader will not be able to find the endpoint.
{{% /notice %}}

3. Run the live loader as follows:

```
docker run -it --rm -v /path/to/g01.json.gz:/tmp/g01.json.gz dgraph/dgraph:v21.03-slash \
dgraph live --slash_grpc_endpoint=<grpc-endpoint>:443 -f /tmp/g01.json.gz -t <api-token>
```

{{% notice "note" %}}
Running this via Docker requires you to use an unreleased tag (either `master` or `v21.03-slash`).
{{% /notice %}}
Loading