GraphQL Repository Queries

Summary

The point of LogScale is to collect data, events from server logs and related metrics. Such data, known as events, are stored in repositories for analysis and monitoring by administrators and others.

Central to using GraphQL is retrieving data from repositories. To that end, you will need to know how to get a list of repositories and information on one or more of them.

List of Repositories

To start, open the API Explorer. Then enter in its left panel, the repositories() query like so, and run it:

graphql
query {
      repositories
         { name, id }
}

This will return a list of repositories, their names and unique identifiers. Below is a brief example of how the results will look. The results would include many more repositories and the identifiers will be more convoluted. These results have been shortened โ€” as indicated by the ellipses โ€” and the values changed.

graphql
{
  "data": {
    "repositories": [
      {
        "name": "humio",
        "id": "abc123"
      },
      {
        "name": "sandbox_123",
        "id": "sandbox_123"
      },
      {
        "name": "our_repo",
        "id": "def456"
      }
   ...
}

You can get plenty more on the repositories, but this is a start and is useful: the names will make you aware of what repositories you have; the identifiers are important because many queries and mutations related to repositories require you to provide this, although a few accept the name.

One Repository

When you want to get information on one repository, you would use the repository() query. Below is the syntax for that query:

graphql
repository(
      name: string!,
      includeHidden: boolean
   ): Repository!

The input is contained within parentheses. There are two input fields. The first is name. The value for it is a string. You'll have to provide it within double-quotes. Notice there is an exclamation point. You don't enter that. It's meant to indicate that the field is required. The second field, includeHidden is not. The value you would give for it would be true, which is the default, or false โ€” neither are given within quotes.

In the syntax you can see there is a colon after the closing parenthsis for the input. You don't enter that. Instead, you wrap the values you want returned within curly-braces.

This query uses the Repository datatype. On the documentation page for the repository() query, at the bottom in the Returned Values section, is a table for that datatype. It lists many values that you can request โ€” and links to other tables for other datatypes for drilling down for more values.

Below is an example of this query in use. When executed, it will retrieve a list of dashboards associated with the repository, their names and their unique identifiers. It requests this through a sub-datatype (Dashboard).

graphql
query {
      repository( name: "our_repo" ) 
        { dashboards { name, id }
         } 
      }
   }

Notice the input is contained within parentheses, and that the returned values requested are contained within curly-braces, and that sub-values requested are contained within inner pair of curly-braces.

As mentioned before, you can use the repositories() query to get plenty on repositories, the same information as repository(), but for all repositories. That means you could do this:

graphql
query {
      repositories
        { name, id,
          dashboards { name, id }
         }
   }

This will return a list of repositories and a list of dashboards for each.

Conclusion

Similar to repositories, or rather sub-sets or merging of repositories, are views. Repositories and views are collectively known as search domains. To access information on views, you'll need to use searchDomain() and searchDomains() โ€” which can also be used for information on repositories.

The queries related to repositories and views are extensive. The amount of administrative information you can retrieve is immense with a large LogScale instance. Use the GraphQL documentation and the API Explorer to experiment and to learn what's ppossible.