Web API On-Prem plugin
The Web API plugin allows you to query data from any HTTP API that returns JSON and visualize that data. This is particularly useful if there isn't a SquaredUp plugin available for your data source.
The Web API On-Prem plugin allows you to add a data source that connects to an API on your internal network.If you're not accessing the API on your internal network, you should instead use the cloud Web API Plugin.
To add a data source click on the + next to Data Sources on the left-hand menu in SquaredUp. Search for the data source and click on it to open the Configure data source page.
An on-prem data source connects a service running in your internal network to SquaredUp. They require an agent installed on a machine that has access to your internal network.
Configuring and deploying an agent
If you have already created an agent in SquaredUp that you can use for this data source, you can skip this step and choose the agent group you want to use while Configuring the data source.
See one of the following, depending on your platform type:
Configuring the data source
Display Name:
You may find it useful to put the API URL in the display name.
Enter a name for your data source. This helps you to identify this data source in the list of your data sources.Agent Group:
Select the Agent Group that contains the agent(s) you want to use.- Base URL:
Enter the base URL of the API to be used for requests, for examplehttps://www.googleapis.com/
- Query arguments:
Add any parameters that should be added to the Base URL. - Authentication:
- None: No authentication required.
- Basic: You must enter a Username and Password.
- OAuth 2: Token-based authentication according to the OAuth 2.0 standard. Many APIs use OAuth 2.0 for authorization, and will require an OAuth provider to include the additional information about how to authorize against the service. If this option is selected, follow the steps in Configure OAuth 2.0 below.
Specify the details for your required OAuth 2.0 flow. For more detailed information see OAuth 2.0 Configuration.
- Token URL:
Enter the URL of the third-party authentication server you are using. For example,https://oauth2.googleapis.com/token
. - Client ID:
Enter the ID provided by your client application. - Client Secret:
Enter the secret provided by your client application. - Authorization Scope:
Enter your required access scopes for the third-party application server you are using. For example, if you are using the Web API plugin to access thehttps://www.googleapis.com/
API and you wish to use thedrive/v3/files
endpoint, you can use the authorization scopehttps://www.googleapis.com/auth/drive.readonly
.
If you require more than one scope, you add them all here separated by spaces.The Web API plugin requires offline access to be requested, which requires the correct scope to be entered, dependent on the authentication server being used:
- Atlassian: Request the
offline_access
scope. - Google APIs: Offline access isn't requested via a scope at all. Instead, you must add the
access_type = offline and include_granted_scopes = true
query arguments to the Authorization URL.
- Atlassian: Request the
- How to send credentials to the Token URL:
Select where you want the client credentials you entered above to be included in the OAuth 2.0 request. - Grant Type:
Select the OAuth 2.0 flow you need to use. Choose from:- Authorization Code: Enter the Authorization URL of the authorization server you are using (for example,
https://www.googleapis.com/
) and then click the Sign In button below. You are redirected to the authorization sign in page.
Upon returning to SquaredUp , if the request was successful, the Sign In button shows you as logged in. - Client Credentials: No additional details are required.
- Password: You must enter a Username and Password.
- Authorization Code: Enter the Authorization URL of the authorization server you are using (for example,
- If you need to send the authorization token in the query URL, select Send authorization with query.
- Token URL:
- Headers can be added if required.
Ignore Certificate errors:
If you activate this checkbox the data source will ignore certificate errors when accessing the server. This is useful if you have self-signed certificates.
- Test endpoint:
Optionally, you can tick Test endpoint to run a test request and see an example payload.Enter the details of an endpoint you'd like to run a test against to see what is returned. The information entered here is only used for the test.
- Endpoint path to test:
Enter an endpoint path. - Additional headers for the test:
Enter any additional header names and values to be used for the test. - HTTP method for the test:
GET or POST - Query arguments for the test GET:
If you chose GET you can optionally add any query arguments to be used for the test. - Body for test POST:
If you chose POST you can optionally enter a JSON string representing the body of the POST request. - Click Send.
- The Result box will show the resulting payload.
- Endpoint path to test:
Restrict access to this data source:
You can enable this option if you only want certain users or groups to have access to the data source, or the permission to link it to new workspaces. See data source access control for more information.The term data source here really means data source instance. For example, a user may configure two instances of the AWS data source, one for their development environment and one for production. In that case, each data source instance has its own access control settings.
By default, Restrict access to this data source is set to off. The data source can be viewed, edited and administered by anyone. If you would like to control who has access to this data source, switch Restrict access to this data source to on.
Use the Restrict access to this data source dropdown to control who has access to the workspace:
- By default, the user setting the permissions for the data source will be given Full Control and the Everyone group will be given Link to workspace permissions.
- Tailor access to the data source, as required, by selecting individual users or user groups from the dropdown and giving them Link to workspace or Full Control permissions.
- If the user is not available from the dropdown, you are able to invite them to the data source by typing in their email address and then clicking Add. The new user will then receive an email inviting them to create an account on SquaredUp. Once the account has been created, they will gain access to the organization.
- At least one user or group must be given Full Control.
- Admin users can edit the configuration, modify the Access Control List (ACL) and delete the data source, regardless of the ACL chosen.
See Access control for more information.
- Click Add.
Next steps
Data streams standardize data from all the different shapes and formats your tools use into a straightforward tabular format.
While creating a tile you can tweak data streams by grouping or aggregating specific columns.
Depending on the kind of data, SquaredUp will automatically suggest how to visualize the result, for example as a table or line graph.
Data streams can be either global or scoped:
- Global data streams are unscoped and return information of a general nature (e.g. "Get the current number of unused hosts").
- A scoped data stream gets information relevant to the specific set objects supplied in the tile scope (e.g. "Get the current session count for these hosts").
Data streams
The following data streams are installed with this plugin.
Data streams standardize data from all the different shapes and formats your tools use into a straightforward tabular format.
While creating a tile you can tweak data streams by grouping or aggregating specific columns.
Depending on the kind of data, SquaredUp will automatically suggest how to visualize the result, for example as a table or line graph.
Data streams can be either global or scoped:
- Global data streams are unscoped and return information of a general nature (e.g. "Get the current number of unused hosts").
- A scoped data stream gets information relevant to the specific set objects supplied in the tile scope (e.g. "Get the current session count for these hosts").
See Data Streams for more information.
HTTP Request
The Web API plugin adds one configurable data stream (HTTP Request) which allows you to create a global data stream to query data from any HTTP API that returns JSON.
The steps for creating the data stream are very similar to those for the Run test endpoint test (when adding a Web API data source), with a couple of additional fields:
- Add a new data tile and scope to an instance of a Web API data source.
- Choose the + <Web API instance name> - HTTP Request data stream.
- Display Name:
Enter a name for this data stream. - The Base URL from the Web API instance is shown.
- Endpoint path:
Enter an endpoint path.A mustache parameter is a dynamic value, the actual value will be inserted to replace the field in curly braces. For example,
{{timeframe.start}}
will insert the start time based on the timeframe configured within the tile, or{{name}}
will insert the name of the object(s) in scope.This data stream supports timeframe parameters:
- Additional headers for this request:
Enter any additional header names and values to be used. You can choose to encrypt a Header Value by clicking the encrypt icon . This turns the field into a password field, so that the value is hidden and the data is stored as encrypted.A mustache parameter is a dynamic value, the actual value will be inserted to replace the field in curly braces. For example,
{{timeframe.start}}
will insert the start time based on the timeframe configured within the tile, or{{name}}
will insert the name of the object(s) in scope.This data stream supports timeframe parameters:
- HTTP method:
Select GET or POST - Query arguments for GET:
If you chose GET you can optionally add any query arguments to be used.A mustache parameter is a dynamic value, the actual value will be inserted to replace the field in curly braces. For example,
{{timeframe.start}}
will insert the start time based on the timeframe configured within the tile, or{{name}}
will insert the name of the object(s) in scope.This data stream supports timeframe parameters:
- Body for POST:
If you chose POST you can optionally enter a JSON string representing the body of the POST request.A mustache parameter is a dynamic value, the actual value will be inserted to replace the field in curly braces. For example,
{{timeframe.start}}
will insert the start time based on the timeframe configured within the tile, or{{name}}
will insert the name of the object(s) in scope.This data stream supports timeframe parameters:
- Click Send. The Result box will show an example of the resulting payload.
- Path to data:
This is where you enter the location of the results set that is returned. The Result box shows you a preview of the data returned, so you can check the location of the data returned, and use that in the Path to data. - Expand inner objects:
Objects inside the requested data path will be used to make extra columns of data.Let's keep this example payload in mind:
const payload = { a1: 'a1', a2: 111, a3: true, arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], obj: { b1: 'b1', b2: 222, b3: true, sub1Arr: [ { x1: 'x1', x2: 6661, x3: { y1: 'y11', y2: 'y21' } }, { x1: 'x2', x2: 6662, x3: { y1: 'y12', y2: 'y22' } } ], subObj: { c1: 'c1', c2: 333, c3: false } } };
If Expand inner objects is unchecked (off)
If Path to data points to an array, so values like
arr
,obj.sub1Arr
, the data stream is going to return one row for each element (with no limit of 10 involved here).arr
will return rows with a single column calledvalue
with all the integers from 1 to 12 (incl.)value 1 2 ... 11 12
obj.sub1Arr
will return two rows and three columns, like:x1 x2 x3 "x1" 6661 "[object Object]" "x2" 6662 "[object Object]"
If Path to data points to a scalar, the data stream will return a single row with a single column called
result
and the value will be the scalar, for example,obj.b2
will return:result 222
If Path to data points to an object, the data stream will return a single row with columns for each of the properties, for example,
obj
will return:b1 b2 b3 sub1Arr subObj "b1" 222 true "[object Array]" "[object Object]"
If Expand inner objects is checked (on)
Behavior differs wherever one of the
[object XXX]
placeholders appeared before.For example,
obj.sub1Arr
will return two rows and four columns, like:x1 x2 x3.y1 x3.y2 "x1" 6661 "y11" "y21" "x2" 6662 "y12" "y22"
Also, nested arrays will be expanded (but only to a maximum of ten elements.
Writing a custom data stream (advanced users)
A custom data stream is a data stream that you, as an advanced user, can write yourself.
Any data stream you create can be edited by clicking the edit button (pencil) next to it in the tile editor, and also from Settings > Advanced > Data Streams.
You may wish to create your own custom data stream for an HTTP Request using the information below. When writing your own data stream you can choose either a global or scoped entry point. You will need to write your own custom data stream if you want a scoped data stream, because the configurable data stream HTTP Request can only create a global data stream.
- In SquaredUp, browse to Settings > Advanced > Data Streams.
- Click Add custom data stream.
- Add your custom data stream by entering the following settings:
- Name:
Enter a display name for your data stream.The display name is the name that you use to identify your data stream in SquaredUp. It has no technical impact and doesn't need to be referenced in the data stream's code.
- Data source:
Choose the data source this data stream is for.
After you've chosen the data source the Entry Point field displays. - Entry Point:
Specify the data stream entry point and enter the Code below.To find out which entry point to select and get code examples for the Code field, see the help below.Each data stream uses an entry point, which can either be global (unscoped) or scoped, and this determines whether the data stream uses the tile scope.
Data streams can be either global or scoped:
- Global data streams are unscoped and return information of a general nature (e.g. "Get the current number of unused hosts").
- A scoped data stream gets information relevant to the specific set objects supplied in the tile scope (e.g. "Get the current session count for these hosts").
- Name:
- Click Save to save your data stream.
Creating a custom data stream allows you to created a scoped data stream, i.e. a data stream that makes use of objects in the scope.
Which entry point do I have to select from the dropdown?
HTTP Request (scoped)
Each data stream uses an entry point, which can either be global (unscoped) or scoped, and this determines whether the data stream uses the tile scope.
Data streams can be either global or scoped:
- Global data streams are unscoped and return information of a general nature (e.g. "Get the current number of unused hosts").
- A scoped data stream gets information relevant to the specific set objects supplied in the tile scope (e.g. "Get the current session count for these hosts").
Code example:
{
"name": "scope example",
"matches": "all",
"dataSourceConfig": {
"endpointPath": "post",
"httpMethod": "post",
"idSeparator": "], [",
"headers": [
{
"key": "header1",
"value": "header1Val"
},
{
"key": "sourceIds",
"value": "[{{sourceIds}}]"
}
],
"expandInnerObjects": true
},
"rowPath": []
}
You should set the matches
statement so that your custom data stream appears when you select the appropriate object types in the tile editor. You can use additional mustache constructs when using the scoped entry point: targetNodes
, sourceId
, sourceIds
in selected dataSourceConfig
parameters as shown below. The separator inserted between sourceId
values in the sourceIds
replacement string can be changed by setting idSeparator
in dataSourceConfig
.
Parameters
Mandatory
The internal name of the data stream. Can be used the refer to this data stream in a tile's JSON instead of using the data stream's internal ID.
Note: Defining the matches
parameter is mandatory.
With the matches
parameter you define for which objects the data stream will be shown in SquaredUp. It works like this:
When you configure a tile, you have to choose its scope. If this scope contains objects you specified here in the matches
parameter, the data stream will be shown in SquaredUp under Data Streams. If the scope doesn't contain objects specified here, the data stream will be hidden.
This keeps things clean and simple since you'll only see the data stream when it's relevant for the scope you chose. As a best practice you should limit the data stream to objects that make sense for the specific use case of this data stream.
Format for matches
:
//If you want to specify only one value of an object property//
"matches": {
"ObjectProperty": {
"type": "equals",
"value": "ValueOfTheObjectProperty"
}
},
//If you want to specify multiple values for an object property//
"matches": {
"ObjectProperty": {
"type": "oneOf",
"values": ["ValueOfTheObjectProperty1", "ValueOfTheObjectProperty2", "ValueOfTheObjectProperty3"]
}
},
Example for limiting a data stream to objects:
If you are using multiple values for the object property, you can decide if you want the data stream to be visible for objects that match all of the criteria or at least one of the criteria.
Lets say you have two values you want objects to have in order for the data stream to be visible for them:
- a
SourceName
property with the valueAppDynamics
(meaning objects that come from the AppDynamics data source) - a
type
property with the valueapp
(meaning application objects)
If you want the data stream to be visible only for objects that match both of the criteria, your code would look like this:
"matches": {
"sourceName": {
"type": "equals",
"value": "AppDynamics"
},
"type": {
"type": "equals",
"value": "app"
}
},
If you want the data stream to be visible for objects that match at least one of the criteria, your code would look like this:
"matches": [
{
"sourceName": {
"type": "equals",
"value": "AppDynamics"
}
},
{
"type": {
"type": "equals",
"value": "app"
}
}
]
Note: If you run into errors when configuring the matches
parameter, check if you're dealing with a global entry point.
Data streams can be either global or scoped:
- Global data streams are unscoped and return information of a general nature (e.g. "Get the current number of unused hosts").
- A scoped data stream gets information relevant to the specific set objects supplied in the tile scope (e.g. "Get the current session count for these hosts").
Global entry points can't use specific objects in the matches
parameter. You can identify global entry points by their name, they have "Global", "No Scope" or "Unscoped" added to their name.
There are two possible options for the matches parameter for global entry points:
Optional
SquaredUp expects data in table form, and here's where you define how the table with your return data will be structured.
The rowpath
(Path to data) will tell SquaredUp which items you want to convert into rows.
Example:
Let's say your return data looks like this:
{
"generalInfo": "some info",
"results": [
{
"name": "object 1",
"tags": [
"tag 1",
"tag 2",
"tag 3"
]
},
{
"name": "object 2",
"tags": [
"tag 1",
"tag 4"
]
}
]
}
Now it depends on what data you want to base your table on, do you want rows per object or per tag?
If you want to see which objects have which tags, your rowpath
would be results
, and your table would look like this:
If you want to turn each tag into a row and see to which objects they are applied, your rowpath
would be results.tags
, and your table would look like this:
As you can see in the example, each parameter gets turned into a column and the items of the parameter you chose as the rowpath
will be turned into rows.
Optional, but recommended
The metadata
parameters are used to describe columns in order to tell SquaredUp what to do with them. You can do multiple things with the metadata
parameters:
- Specify how SquaredUp should interpret the columns you return and - to an extent - how their content displayed. You do this by giving each column a shape.
The shape you assign to a column tells SquaredUp what the column contains (for example, a number, a date, a currency, a URL, etc.). Based on the shape SquaredUp decides how to display this column, for example to display a URL as a clickable link.
- Filter out or just hide columns.
Only the columns you define inmetadata
will be returned in the results. This helps you to filter out columns you don't need. If you need the content of a column but don't want to display it, you can use thevisible
parameter. - Give columns a nicely readable display name.
- Assign a specific role to columns .
The role you assign to a column tells SquaredUp the purpose of the column. For example, if you have two different columns that contain numbers, you need to assign the role
value
to the column that contains the actual value you want to use in your visualization.
If you don't specify any metadata, all columns will be returned and SquaredUp will do its best to determine which columns should be used for which purpose. If you're returning pretty simple data, for example just a string and a number, this can work fine. But if you're returning two columns with numbers it gets trickier for SquaredUp to figure out which one is the value and which one is just an ID or some other number.
Parameters:
Before you start specifying metadata, leave them empty at first and get all the raw data with your new data stream once.
In order to do this, finish creating your custom data stream without metadata and create a tile with this data stream. The Table visualization will show you all raw data.
This will give you an overview about all columns and their content and help you decide which columns you need and what their shapes and roles should be. It's also essential for getting the correct column name to reference in the name
parameter.
Use this information to go back to the data stream configuration and specifying the metadata.
There are many different shapes you can use for your columns and the list of possible shapes gets expanded constantly:
- Basic types, like:
boolean
,date
,number
,string
- Currency types that get displayed with two decimal values and their currency symbol (for example $23,45), like:
currency
(generic currency),eur
,gbp
,usd
- Data types, like:
bytes
,kilobytes
,megabytes
- Time types, like:
seconds
,milliseconds
,timespan
- The status type :
state
- Utility types, like:
customUniturl
(will be displayed as a link)
Tip:
Some shapes can be configured.
If a shape is configurable, you can edit how the shape displays data in SquaredUp.