[role="xpack"]
[[canvas-server-functions]]
=== Canvas server functions

These functions can only execute on the server. This may be for performance
or security reasons, or because the function uses an API only available on the 
{kib} server. If the expression is executing in the browser, it will transfer to 
the server when it hits one of these functions.

A *** denotes a required argument.

[float]
=== demodata

A mock data set that includes project CI times with usernames, countries, and run phases.

*Accepts:* filter

[cols="3*^<"]
|===
|Argument |Type |Description

|_Unnamed_ (Alias: `type`)
|string
|The name of the demo data set to use  (default: `ci`)
|===

*Returns:* datatable


[float]
=== esdocs

Queries {es} and gets back raw documents. Specify the fields you want to receive, 
especially if you are asking for a lot of rows.

*Accepts:* filter

[cols="3*^<"]
|===
|Argument |Type |Description

|index
|string
|Specify an index pattern, for example, "logstash-*"  (default is `_all`)

|_Unnamed_ (Aliases: `query`, `q`)
|string
|A Lucene query string (default: `_index:.kibana`)

|sort
|string
|Sort directions as "field, direction", for example, "@timestamp, desc" or "bytes, asc"

|fields
|string
|Comma separated list of fields. Fewer fields will perform better

|metaFields
|string
|Comma separated list of meta fields, for example, "_index,_type"

|count
|number
|The number of docs to pull back. Smaller numbers perform better (default: `100`)
|===

*Returns:* datatable


[float]
=== escount

Queries {es} for a count of the number of hits matching a query.

*Accepts:* filter

[cols="3*^<"]
|===
|Argument |Type |Description

|index
|string
|Specify an index pattern, for example, "logstash-*"  (default: `all`)

|_Unnamed_  (Alias: `query`, `q`)
|string
|A Lucene query string (default: `"-_index:.kibana"`)
|===

*Returns:* number


[float]
=== essql

Specifies an {es} SQL.

*Accepts:* filter

[cols="3*^<"]
|===
|Argument |Type |Description

|_Unnamed_*  (Alias: `query`, `q`)
|string
|An SQL query

|count
|number
|The default is `1000`
|===

*Returns:* datatable


[float]
=== pointseries

Turns a datatable into a point series model. Currently Canvas differentiates measure 
from dimensions by looking for a <<canvas-tinymath-functions, Tiny Math function>>. If you enter a TinyMath 
expression in your argument, Canvas treats that argument as a measure. Otherwise, it 
is a dimension. Dimensions are combined to create unique keys. Measures are 
then deduplicated by those keys using the specified TinyMath function.

*Accepts:* datatable

[cols="3*^<"]
|===
|Argument |Type |Description

|x
|string
|The values along the X-axis

|y
|string
|The values along the Y-axis

|color
|string
|An expression to use in determining the mark's color

|size
|string
|For elements that support it, the size of the marks

|text
|string
|For use in charts that support it, the text to show in the mark
|===

*Returns:* pointseries


[float]
=== server

Forces the interpreter to return to the server.

*Accepts:* Anything or nothing

*Returns:* Depends on your input and arguments
&nbsp;

[float]
=== timelion

Uses Timelion to extract one or more time series from many sources.

*Accepts:* filter

[cols="3*^<"]
|===
|Argument |Type |Description

|_Unnamed_ (Aliases: `query`, `q`)
|string
|A Timelion query (default: `".es(*)"`)

|interval
|string
|Bucket interval for the time series (default: `auto`)

|from
|any
|{es} date math string for the start of the time range (default: `now-1y`)

|to
|any
|{es} date math string for the end of the time range (default: `now`)

|timezone
|any
|Time zone for the time range (default: `UTC`)
|===

*Returns:* datatable

