Template API Reference

Objects

`notebook` : object

Functions for creating Fiberplane Notebooks

`cell` : object

Functions for creating notebook cells

`format` : object

Functions for formatting text

Functions

`snippet(cells)`Array.<Cell>

Function for creating Snippets, or reusable groups of cells.

notebook : object

Functions for creating Fiberplane Notebooks

Kind: global namespace
Example

fp.notebook.new('My Notebook')
 .setTimeRangeRelative(minutes=60)
 .addCells([...])

notebook.Notebook

A Fiberplane Notebook.

Kind: static class of notebook
See: notebook.new to create a Notebook

notebook.setTimeRangeRelative(minutes)Notebook

Set the notebook time range relative to when it is created.

For example, specifying minutes=60 will set the start timestamp to 60 minutes before the notebook is created. The end timestamp will automatically be set to the time when the notebook is created.

By default, the time range is set to 60 minutes relative to when the notebook is created.

Kind: instance method of Notebook

ParamType
minutesnumber

notebook.setTimeRangeAbsolute(from, to)Notebook

Set the time range of the notebook using absolute timestamps.

Note: in most cases, you will want to use [notebook#setTimeRangeRelative](notebook#setTimeRangeRelative) instead.

Kind: instance method of Notebook

ParamTypeDescription
fromstring

ISO 8601/RFC 3339 formatted start timestamp

tostring

ISO 8601/RFC 3339 formatted end timestamp

notebook.setSelectedDataSource(providerType, dataSourceName, proxyName)Notebook

Select a data source for the given provider type.

The workspace defaults will be used if none is specified.

Kind: instance method of Notebook

ParamTypeDescription
providerTypestring

The type of provider to select the data source for

dataSourceNamestring

The name of the data source to select for the given provider type

proxyNamestring | null

If the data source is configured in a proxy, the name of the proxy

notebook.addCell(cell)Notebook

Add a single cell to the notebook.

Kind: instance method of Notebook

ParamType
cellCell

notebook.addCells(cells)Notebook

Add an array of cells to the notebook.

Note: this function supports nested arrays of cells.

Kind: instance method of Notebook

ParamType
cellsArray.<Cell>

notebook.addLabel(key, value)Notebook

Add a single label to the notebook.

Kind: instance method of Notebook

ParamTypeDescription
keystring

Key of the label

valuestring

Value of the label

Example

notebook.addLabel(key='service', value='api')

notebook.addLabels(labels)Notebook

Add an object of labels to the notebook.

Kind: instance method of Notebook

ParamTypeDescription
labelsobject

Map of keys and values

Example

notebook.addLabels({
 service: 'api',
 severity: 'high'
})

notebook.new(title)Notebook

Create a new notebook with the given title.

Kind: static method of notebook

Param
title

cell : object

Functions for creating notebook cells

Kind: global namespace
Example (Adding cells to a notebook)

notebook.addCells([
  cell.h1('Title'),
  cell.text('Hello world!'),
  // See below for all of the available cell types
])

cell.Cell

An individual cell in a notebook

Kind: static class of cell

cell.setReadOnly(readOnly)Cell

Lock the cell

Kind: instance method of Cell

ParamTypeDefault
readOnlybooleantrue

cell.heading : object

Heading cells

Kind: static namespace of cell

heading.h1(content, readOnly)Cell

Create an H1 cell

Also accessible as cell.h1

Kind: static method of heading

ParamTypeDefaultDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

readOnlybooleanfalse

Whether the cell is locked

heading.h2(content, readOnly)Cell

Create an H2 cell

Also accessible as cell.h2

Kind: static method of heading

ParamTypeDefaultDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

readOnlybooleanfalse

Whether the cell is locked

heading.h3(content, readOnly)Cell

Create an H3 cell

Also accessible as cell.h3

Kind: static method of heading

ParamTypeDefaultDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

readOnlybooleanfalse

Whether the cell is locked

cell.list : object

Helper functions for easily creating lists

Kind: static namespace of cell

list.ordered(cells, startNumber, level, readOnly)Array.<Cell>

Create an ordered list

Also accessible as cell.ol and cell.orderedList

Kind: static method of list

ParamTypeDefaultDescription
cellsArray.<(string|cell.Cell|Array)>

An array of strings, cells, or nested lists. Strings will become numbered list items. Other cell types are included as they are. Nested lists have their indentation level automatically incremented.

startNumbernumber1

Starting number for the whole list. This function automatically handles numbering for all items in this list.

levelnumber | null

Specify the indentation level. The top level is null, the first indented level is 1, and so on

readOnlybooleanfalse

Whether the cells are locked

list.unordered(cells, level, readOnly)Array.<Cell>

Create an unordered list

Also accessible as cell.ul and cell.unorderedList

Kind: static method of list

ParamTypeDefaultDescription
cellsArray.<(string|cell.Cell|Array)>

An array of strings, cells, or nested lists. Strings will become list items. Other cell types are included as they are. Nested lists have their indentation level automatically incremented.

levelnumber | null

Specify the indentation level. The top level is null, the first indented level is 1, and so on

readOnlybooleanfalse

Whether the cells are locked

cell.listItem : object

Individual list items.

In most cases, you will want to use [Cell.list](Cell.list) instead.

Kind: static namespace of cell

listItem.ordered(content, startNumber, level, readOnly)Cell

Create an ordered list item

Kind: static method of listItem

ParamTypeDefaultDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

startNumbernumber | null

Specify the starting number. Mostly useful if you want to start the list at a number other than 1.

levelnumber | null

Specify the indentation level. The top level is null, the first indented level is 1, and so on

readOnlybooleanfalse

Whether the cell is locked

listItem.unordered(content, level, readOnly)Cell

Create an unordered list item

Kind: static method of listItem

ParamTypeDefaultDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

levelnumber | null

Specify the indentation level. The top level is null, the first indented level is 1, and so on

readOnlybooleanfalse

Whether the cell is locked

cell.checkbox(checked, content, level, readOnly)Cell

Create a checkbox cell

Kind: static method of cell

ParamTypeDefaultDescription
checkedbooleanfalse

Whether the checkbox is checked

contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

levelnumber | null

Specify the indentation level. The top level is null, the first indented level is 1, and so on

readOnlybooleanfalse

Whether the cell is locked

cell.code(checked, content, syntax, readOnly)Cell

Create a code cell

Kind: static method of cell

ParamTypeDefaultDescription
checkedbooleanfalse

Whether the checkbox is checked

contentstring"''"

Cell text content

syntaxstring | nullnull

Specify the syntax to use for rendering the code

readOnlybooleanfalse

Whether the cell is locked

cell.divider(readOnly)Cell

Create a divider (horizontal rule) cell

Kind: static method of cell

ParamTypeDefaultDescription
readOnlybooleanfalse

Whether the cell is locked

cell.provider(intent, title, queryData, readOnly)

Create a provider cell

Kind: static method of cell

ParamTypeDefaultDescription
intentstring

The intent of the new provider cell

titlestring

Title for the new provider cell

queryDatastring

Query data that the provider will understand

readOnlybooleanfalse

Whether the cell is locked

cell.prometheus(content, readOnly)Cell

Create a Prometheus query cell

Kind: static method of cell

ParamTypeDefaultDescription
contentstring"''"

Prometheus query

readOnlybooleanfalse

Whether the cell is locked

cell.elasticsearch(content, readOnly)Cell

Create an Elasticsearch query cell

Kind: static method of cell

ParamTypeDefaultDescription
contentstring"''"

Elasticsearch query

readOnlybooleanfalse

Whether the cell is locked

cell.loki(content, readOnly)Cell

Create a Loki query cell

Kind: static method of cell

ParamTypeDefaultDescription
contentstring"''"

Loki query

readOnlybooleanfalse

Whether the cell is locked

cell.text(content, readOnly)Cell

Create a plain text cell

Kind: static method of cell

ParamTypeDefaultDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

readOnlybooleanfalse

Whether the cell is locked

cell.image(url, readOnly)

Create an image cell

Kind: static method of cell

ParamTypeDefaultDescription
urlstring

URL of the image

readOnlybooleanfalse

Whether the cell is locked

format : object

Functions for formatting text

Kind: global namespace
Example

fp.format.bold('hello')

Example (Nested formatting)

fp.format.bold(fp.format.italic('hello'))

Example (Creating a cell with different text formats)

fp.cell.text(['hello ', fp.format.bold('world '), fp.format.italics('!')])
// This is equivalent to:
fp.cell.text(fp.format.raw('hello ').bold('world ').italics('!'))

format.FormattedContent

A class representing formatted text. Each of the formatting functions can be called as methods to append text with the given formatting.

Kind: static class of format

formattedContent.raw(content)FormattedContent

Add raw text. Note that if this is added inside a formatting helper, the outer formatting will be applied to this text.

Kind: instance method of FormattedContent

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

formattedContent.bold(content)FormattedContent

Add bold text

Kind: instance method of FormattedContent

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

formattedContent.italics(content)FormattedContent

Add italicized text

Kind: instance method of FormattedContent

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

formattedContent.code(content)FormattedContent

Add code-formatted text

Kind: instance method of FormattedContent

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

formattedContent.highlight(content)FormattedContent

Add highlighted text

Kind: instance method of FormattedContent

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

formattedContent.strikethrough(content)FormattedContent

Add strikethrough text

Kind: instance method of FormattedContent

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

formattedContent.underline(content)FormattedContent

Add underlined text

Kind: instance method of FormattedContent

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

formattedContent.link(content, url)FormattedContent

Add a link

Kind: instance method of FormattedContent

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

urlstring | null

The URL of the link. If none is provided, the content will be used as the link URL

Example

fmt.link('Example', 'https://example.com')

Example

fmt.link('https://example.com')

formattedContent.mention(userName, userId)FormattedContent

Add a mention

Kind: instance method of FormattedContent

ParamTypeDescription
userNamestring

The username to mention

userIdstring

The ID of the user to mention

formattedContent.timestamp(timestamp)FormattedContent

Add a timestamp

Kind: instance method of FormattedContent

ParamTypeDescription
timestampstring

The RFC3339-formatted timestamp to add

formattedContent.label(key, url)FormattedContent

Add a label

Kind: instance method of FormattedContent

ParamTypeDescription
keystring

The label's key

urlstring

The label's value (optional)

format.raw(content)FormattedContent

Add raw text. Note that if this is added inside a formatting helper, the outer formatting will be applied to this text.

Kind: static method of format

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

format.bold(content)FormattedContent

Add bold text

Kind: static method of format

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

format.code(content)FormattedContent

Add code-formatted text

Kind: static method of format

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

format.highlight(content)FormattedContent

Add highlighted text

Kind: static method of format

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

format.italics(content)FormattedContent

Add italicized text

Kind: static method of format

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

format.underline(content)FormattedContent

Add underlined text

Kind: static method of format

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

format.strikethrough(content)FormattedContent

Add strikethrough text

Kind: static method of format

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

format.link(content, url)FormattedContent

Add a link

Kind: static method of format

ParamTypeDescription
contentstring | FormattedContent | Array.<(string|format.FormattedContent)>

The content to add

urlstring | null

The URL of the link. If none is provided, the content will be used as the link URL

Example

fmt.link('Example', 'https://example.com')

Example

fmt.link('https://example.com')

snippet(cells)Array.<Cell>

Function for creating Snippets, or reusable groups of cells.

Kind: global function

ParamType
cellsArray.<Cell>

Example

fp.snippet([
 c.text('Hello, world!'),
 c.code('This is a snippet'),
])