Data sources
You can use various HTTP methods to load, create, update, and delete data sources.
Data sources are called log sources in the REST API files.
Load (GET
method)
To load
all the data sources and associated tags, use a
GET
method
and the following URL:https://<server>:<port>/Unity/Logsources?pattern=*
The
data sources are returned in a JSON array. The returned values for
each data source are listed in the table.
Parameter | Description |
---|---|
logsource_pk |
The ID of the log source. |
name |
The name of the tag or log source. |
description |
Description for the data source. |
tag_id |
The ID for any tags that are associated with the data source. |
service_topology |
The name of the group hierarchy that is associated with the data source. |
For example:
[
{
"logsource_pk": 1,
"name": "_alerts",
"description": "Built-in datasource for indexing alerts",
"tag_id": 4,
"service_topology": ""
},
{
"logsource_pk": 2,
"name": "access1.log",
"description": "",
"tag_id": 7,
"service_topology": "service:cloud provider application
> middleware:webserver > hostname:cldegd58"
},
.....
]
To load the details for a specified data source,
use a
GET
method and the following URL:https://<server>:<port/Unity/DataSourceConfig?
datasourceconfigid=<logsource_pk>
where <logsource_pk> is
the ID of the log source that you want to load.The data sources
are returned in a JSON array. The returned values are described in
the following table:
For example:
Returned value | Description |
---|---|
description |
Description for the data source. |
configType |
The type of data source. The values are custom, local, and remote. |
rollingfile |
If you collect rolling log files with this data source, this value is true. If you do not, it is false. |
hostname |
The host name for the server where the data source resides. |
password |
The password for the user name that is associated with the data source. |
sourceType |
The number which represents the source ype that is associated with the data source. |
datasourcepath |
The full path and log file name for the log file records that the data source loads into Log Analysis. |
logsource_pk |
The ID for the log source. |
name |
The name of the data source. |
filepattern |
The file pattern that is associated with the data source. |
collectionid |
The identifier for the collection that is associated with the data source. |
username |
The ID for the user name who created the data sources. |
group |
The name of the group hierarchy that is associated with the data source, if any. |
{
"description": "",
"configType": "custom",
"rollingfile": false,
"hostname": "cldegd60",
"password": null,
"sourceType": 3,
"datasourcepath":
"DemoWinOSEvents/WinOSEvents.txt",
"logsource_pk": 11,
"name": "sample-WinOS-events",
"filepattern": null,
"collectionId": 24,
"username": null,
"group": ""
}
Create (POST
method)
To
create a new data source, use a
POST
method and the
following URL:https://<server>:<port>/Unity/DataSourceConfig
You
define the parameter values in the JSON format in the HTTP message
body. The input parameters are listed in the table.
Parameter | Description |
---|---|
configType |
The type of data source. You must use custom. |
hostname |
The host name of the machine where the data that the data source collects resides. |
username |
The user name that is associated with the data source. This parameter is optional. |
password |
The password that is associated with the user name. This parameter is optional. |
datasourcepath |
The full path and log file name of the log file that is loaded by this data source. |
sourceType |
The identifier of the source type that is associated with the data source. |
rollingfile |
If you want to use the data source to collect rolling log files, set this parameter to True. If you do not, set it to False. |
filepattern |
The file pattern that is associated with the data source. This parameter is optional. |
name |
The name of the data source. |
description |
The description for the data source. This parameter is optional. |
group |
The name of the group hierarchy that is associated with the data source. This parameter is optional. |
For example:
{
"configType": "local",
"hostname": "example.com",
"username": null,
"password": null,
"datasourcepath":
"/home/...../SystemOut2.log",
"sourceType": <sourcetype id>,
"rollingfile": false,
"filepattern": null,
"name": "Test",
"description": "",
"group": ""
}
The following table summarizes some of the response
codes. The error code for all of these errors is
400 (Bad
request)
.
Error | Input JSON | Example API response in JSON |
---|---|---|
The source type ID that is specified in the input JSON is not valid. |
|
{
|
The collection ID that is specified in the input JSON is not valid. |
|
{
|
The host name and log path combination is already in use. | and
|
{
|
The data source name that is specified in the input JSON is already in use. |
|
{
|
The data source name input that is specified in the JSON is blank or contains more than 30 characters. |
|
{
|
Update (PUT
method)
To
update a data source, use a
PUT
method and the following
URL:https://<server>:<port>/Unity/DataSourceConfig
You
define the parameter values in the JSON format in the HTTP message
body. The input values are the same as the ones that are specified
in table 3.
For example:
Parameter | Description |
---|---|
logsource_pk |
The identifier for the log source that you want to load. |
configType |
The type of data source. This must be custom. |
hostname |
The host name of the machine where the data that the data source collects resides. |
username |
The user name that is associated with the data source. This parameter is optional. |
password |
The password that is associated with the user name. This parameter is optional. |
datasourcepath |
The full path and log file name of the log file that is loaded by this data source. |
sourceType |
The identifier of the source type that is associated with the data source. |
rollingfile |
If you want to use the data source to collect rolling log files, set this parameter to True. If you do not, set it to False. |
filepattern |
The file pattern that is associated with the data source. This parameter is optional. |
name |
The name of the data source. |
description |
The description for the data source. This parameter is optional. |
group |
The name of the group hierarchy that is associated with the data source. This parameter is optional. |
{
"description":"",
"configType":"local",
"rollingfile":false,
"hostname":"nc91209819.in.ibm.com",
"password":null,
"sourceType":"7",
"datasourcepath":"/home/unity/IBM/db2diag.log",
"logsource_pk":1,
"name":"sample-db2",
"filepattern":null,
"collectionId":14,
"username":null,
"group":"Service:IPO"
}
Delete (DELETE
method)
To
update a data source, use a
DELETE
method and the
following URL:https://<server>:<port>/Unity/DataSourceConfig?logsource_pk
=<logsource_pk>
where <logsource_pk>
is the identifier of the log source that you want to delete.