GraphQL

Humio has chosen GraphQL for our main API because it offers significantly more flexibility for API clients. GraphQL allows you to precisely specify the data you require, which allows you to call a single endpoint to get everything you need. This makes creating integrations and clients for Humio much easier.

The GraphQL API is a public developer preview. It may change without notice.

The GraphQL API is documented by our interactive API explorer:

  • https://$YOUR_HUMIO_URL/docs/api-explorer (where $YOUR_HUMIO_URL is the URL for your Humio Cloud Account.)
  • $YOUR_HUMIO_URL/docs/api-explorer (Where $YOUR_HUMIO_URL is the hostname for self-hosted install.)

New to GraphQL?

You don’t need any special tools to use GraphQL. GraphQL is based on HTTP, and all you need is curl to send requests; responses are returned as JSON.

Resources for Learning GraphQL

API Explorer

Humio has a built-in API explorer bundled with each installation. You can find it under:

http://$YOUR_HUMIO_URL:$PORT/docs/api-explorer

The newest version is always available under:

  • https://$YOUR_HUMIO_URL/docs/api-explorer (where $YOUR_HUMIO_URL is the URL for your Humio installation.)

Examples

These examples are geared toward self-hosted setups and assume they’re being executed from a Humio server. You can also run them against the public Humio hostname using an actual user API token (which is obtained from the “Your Account” area from the menu on the right in the header). This is being done for simplicity’s sake and the fact that it will work on any installation if executed from the server running Humio.

List Users

curl -v -XPOST -H "Content-Type: application/json" \
  -H "Authorization: bearer $(cat /data/humio-data/local-admin-token.txt)" \
  http://127.0.0.1:8080/graphql \
  -d '{ "query": "{ accounts { username } }" }'

Add User

curl -v -XPOST -H "Content-Type: application/json" \
  -H "Authorization: bearer $(cat /data/humio-data/local-admin-token.txt)" \
  http://127.0.0.1:8080/graphql \
  -d '{ "query": "mutation { addUser(input: { username: \"user@example.com\" }) { user { id } } }" }'

Remove User

curl -v -XPOST -H "Content-Type: application/json" \
  -H "Authorization: bearer $(cat /data/humio-data/local-admin-token.txt)" \
  http://127.0.0.1:8080/graphql \
  -d '{ "query": "mutation { removeUser(input: { username: \"user@example.com\" }) { clientMutationId } }" }'

Add User to Repository

curl -v -XPOST -H "Content-Type: application/json" \
  -H "Authorization: bearer $(cat /data/humio-data/local-admin-token.txt)" \
  http://127.0.0.1:8080/graphql \
  -d '{ "query": "mutation { addMember(searchDomainName: \"your-repo-name-here\", username: \"user@example.com\", hasMembershipAdminRights:false, hasDeletionRights:false)  { clientMutationId } }" }'

Why use both GraphQL and REST?

Some resources in Humio must be accessed with REST. This is both for historical reasons and that we feel that REST is better suited for our Querying API. Also, HTTP streaming is more appropriate for our streaming results, though we may add support for GraphQL Subscriptions in the future.