REST API

Analytics Security Facede API documentation version v1

{schema}://{host}/api/{version}

  • schema: required(one of http, https - default: http)
  • host: required(string - default: localhost)
  • version: required(v1)

Pipeline

Operations on pipelines.

/_ingest/pipeline/{pipelineID} put get delete

put /_ingest/pipeline/{pipelineID}

Create or update existing ingest pipeline.

Secured by oauth_2_0 with scopes:
  • application:update

Analytics Security Facede supports OAuth 2.0 for authenticating all API requests.

URI Parameters

  • pipelineID: required(string)

    Pipeline ID.

    Example:

    application-bspu4tiikfmmfgrk47jg

Body

Media type: application/json

Type: asf-api-types.IngestPipelineRequest

Example:

{
  "processors": [
    {
      "set": {
        "if": "ctx.dataSample.tp > 30",
        "field": "dataSample.temperatureLevel",
        "value": "HIGH"
      }
    },
    {
      "set": {
        "if": "ctx.dataSample.tp >= 0",
        "field": "dataSample.temperatureLevel",
        "value": "NORMAL"
      }
    },
    {
      "set": {
        "if": "ctx.dataSample.tp < 0",
        "field": "dataSample.temperatureLevel",
        "value": "LOW"
      }
    },
    {
      "script": {
        "lang": "painless",
        "source": "ctx['dataSample']['computedValue'] = Math.log(ctx['dataSample']['ozone_sensor'] * 2) + ctx['dataSample']['PM_2_sensor'];"
      }
    }
  ]
}

HTTP status code 200

Pipeline is successfully created.

Body

Media type: application/json

Type: asf-api-types.Acknowledged

Example:

{
  "acknowledged": true
}

Secured by oauth_2_0

Headers

  • Authorization: optional (string)

    Used to send a valid OAuth 2 access token. Example: "Authorization: Bearer 'access_token'" where 'access_token' must be replaced by a valid OAuth access token. This header is needed only if API authentication is enabled for the service.

get /_ingest/pipeline/{pipelineID}

Retrieves pipeline by ID.

Secured by oauth_2_0 with scopes:
  • application:read

Analytics Security Facede supports OAuth 2.0 for authenticating all API requests.

URI Parameters

  • pipelineID: required(string)

    Pipeline ID.

    Example:

    application-bspu4tiikfmmfgrk47jg

HTTP status code 200

Pipeline is successfully retrieved.

Body

Media type: application/json

Type: asf-api-types.IngestPipelineResponse

Example:

{
  "e02e0679-2de5-48af-a2f0-c650356dc739-application-bspu4tiikfmmfgrk47jg": {
    "processors": [
      {
        "set": {
          "if": "ctx.dataSample.tp > 30",
          "field": "dataSample.temperatureLevel",
          "value": "HIGH"
        }
      },
      {
        "set": {
          "if": "ctx.dataSample.tp >= 0",
          "field": "dataSample.temperatureLevel",
          "value": "NORMAL"
        }
      },
      {
        "set": {
          "if": "ctx.dataSample.tp < 0",
          "field": "dataSample.temperatureLevel",
          "value": "LOW"
        }
      },
      {
        "script": {
          "lang": "painless",
          "source": "ctx['dataSample']['computedValue'] = Math.log(ctx['dataSample']['ozone_sensor'] * 2) + ctx['dataSample']['PM_2_sensor'];"
        }
      }
    ]
  }
}

Secured by oauth_2_0

Headers

  • Authorization: optional (string)

    Used to send a valid OAuth 2 access token. Example: "Authorization: Bearer 'access_token'" where 'access_token' must be replaced by a valid OAuth access token. This header is needed only if API authentication is enabled for the service.

delete /_ingest/pipeline/{pipelineID}

Deletes pipeline by ID.

Secured by oauth_2_0 with scopes:
  • application:delete

Analytics Security Facede supports OAuth 2.0 for authenticating all API requests.

URI Parameters

  • pipelineID: required(string)

    Pipeline ID.

    Example:

    application-bspu4tiikfmmfgrk47jg

HTTP status code 200

Pipeline is successfully deleted.

Body

Media type: application/json

Type: asf-api-types.Acknowledged

Example:

{
  "acknowledged": true
}

Secured by oauth_2_0

Headers

  • Authorization: optional (string)

    Used to send a valid OAuth 2 access token. Example: "Authorization: Bearer 'access_token'" where 'access_token' must be replaced by a valid OAuth access token. This header is needed only if API authentication is enabled for the service.

/_ingest/pipeline/simulate/{pipelineID} post

post /_ingest/pipeline/simulate/{pipelineID}

Simulate pipeline by ID.

Secured by oauth_2_0 with scopes:
  • application:update

Analytics Security Facede supports OAuth 2.0 for authenticating all API requests.

URI Parameters

  • pipelineID: required(string)

    Pipeline ID.

    Example:

    application-bspu4tiikfmmfgrk47jg

Body

Media type: application/json

Type: asf-api-types.IngestPipelineRequestSimulateWithPipelineID

Example:

{
  "docs": [
    {
      "_source": {
        "appVersionName": "bspu4tiikfmmfgrk47jg-v1",
        "appName": "bspu4tiikfmmfgrk47jg",
        "@timestamp": "2021-05-26T00:17:08.903Z",
        "serverTimestamp": 1621988228880,
        "dataSample": {
          "humidity_sensor": 54,
          "PM_2_sensor": 534,
          "air_quality_index": 5,
          "PM_10_sensor": 270,
          "ozone_sensor": 297,
          "pressure": 828.9828409507737,
          "nitrogen_dioxide_sensor": 764,
          "tp": 11
        },
        "@version": "1",
        "endpointId": "4aae8471-5c7d-499a-9e5b-dafaba23ff66",
        "tenantId": "d6312fc1-4c5d-4d1d-8c8c-8ab16435b560"
      }
    }
  ]
}

HTTP status code 200

Simulated pipeline result by ID.

Body

Media type: application/json

Type: asf-api-types.IngestPipelineResponseSimulateWithPipelineID

Example:

{
  "docs": [
    {
      "doc": {
        "_index": "_index",
        "_type": "_doc",
        "_id": "_id",
        "_source": {
          "@timestamp": "2021-05-26T00:17:08.903Z",
          "serverTimestamp": 1621988228880,
          "appName": "bspu4tiikfmmfgrk47jg",
          "endpointId": "4aae8471-5c7d-499a-9e5b-dafaba23ff66",
          "@version": "1",
          "tenantId": "d6312fc1-4c5d-4d1d-8c8c-8ab16435b560",
          "dataSample": {
            "computedValue": 540.3868793193626,
            "ozone_sensor": 297,
            "nitrogen_dioxide_sensor": 764,
            "PM_2_sensor": 534,
            "temperatureLevel": "NORMAL",
            "PM_10_sensor": 270,
            "humidity_sensor": 54,
            "pressure": 828.9828409507737,
            "air_quality_index": 5,
            "tp": 11
          },
          "appVersionName": "bspu4tiikfmmfgrk47jg-v1"
        },
        "_ingest": {
          "timestamp": "2021-12-13T15:09:15.996099824Z"
        }
      }
    }
  ]
}

Secured by oauth_2_0

Headers

  • Authorization: optional (string)

    Used to send a valid OAuth 2 access token. Example: "Authorization: Bearer 'access_token'" where 'access_token' must be replaced by a valid OAuth access token. This header is needed only if API authentication is enabled for the service.

/_ingest/pipeline/simulate/ post

post /_ingest/pipeline/simulate/

Simulate pipeline with body data.

Body

Media type: application/json

Type: asf-api-types.IngestPipelineSimulateRequest

Example:

{
  "pipeline": {
    "processors": [
      {
        "set": {
          "if": "ctx.dataSample.tp > 30",
          "field": "dataSample.temperatureLevel",
          "value": "HIGH"
        }
      },
      {
        "set": {
          "if": "ctx.dataSample.tp >= 0",
          "field": "dataSample.temperatureLevel",
          "value": "NORMAL"
        }
      },
      {
        "set": {
          "if": "ctx.dataSample.tp < 0",
          "field": "dataSample.temperatureLevel",
          "value": "LOW"
        }
      },
      {
        "script": {
          "lang": "painless",
          "source": "ctx['dataSample']['computedValue'] = Math.log(ctx['dataSample']['ozone_sensor'] * 2) + ctx['dataSample']['PM_2_sensor'];"
        }
      }
    ]
  },
  "docs": [
    {
      "_index": "d6312fc1-4c5d-4d1d-8c8c-8ab16435b560-bspu4tiikfmmfgrk47jg-2021.05.26",
      "_type": "_doc",
      "_id": "DjoIpnkBs0b6s2dRQFFN",
      "_score": 10.692778,
      "_source": {
        "appVersionName": "bspu4tiikfmmfgrk47jg-v1",
        "appName": "bspu4tiikfmmfgrk47jg",
        "@timestamp": "2021-05-26T00:17:08.903Z",
        "serverTimestamp": 1621988228880,
        "dataSample": {
          "humidity_sensor": 54,
          "PM_2_sensor": 534,
          "air_quality_index": 5,
          "PM_10_sensor": 270,
          "ozone_sensor": 297,
          "pressure": 828.9828409507737,
          "nitrogen_dioxide_sensor": 764,
          "tp": 11
        },
        "@version": "1",
        "endpointId": "4aae8471-5c7d-499a-9e5b-dafaba23ff66",
        "tenantId": "d6312fc1-4c5d-4d1d-8c8c-8ab16435b560"
      }
    }
  ]
}

HTTP status code 200

Simulated pipeline result.

Body

Media type: application/json

Type: asf-api-types.IngestPipelineSimulateResponse

Example:

{
  "docs": [
    {
      "doc": {
        "_index": "_index",
        "_type": "_doc",
        "_id": "_id",
        "_source": {
          "@timestamp": "2021-05-26T00:17:08.903Z",
          "serverTimestamp": 1621988228880,
          "appName": "bspu4tiikfmmfgrk47jg",
          "endpointId": "4aae8471-5c7d-499a-9e5b-dafaba23ff66",
          "@version": "1",
          "tenantId": "d6312fc1-4c5d-4d1d-8c8c-8ab16435b560",
          "dataSample": {
            "computedValue": 540.3868793193626,
            "ozone_sensor": 297,
            "nitrogen_dioxide_sensor": 764,
            "PM_2_sensor": 534,
            "temperatureLevel": "NORMAL",
            "PM_10_sensor": 270,
            "humidity_sensor": 54,
            "pressure": 828.9828409507737,
            "air_quality_index": 5,
            "tp": 11
          },
          "appVersionName": "bspu4tiikfmmfgrk47jg-v1"
        },
        "_ingest": {
          "timestamp": "2021-12-13T15:09:15.996099824Z"
        }
      }
    }
  ]
}

Template

Operations on template.

/{tenantID}-{applicationName}/_template put get

put /{tenantID}-{applicationName}/_template

Index templates allow to define templates that will automatically be applied to new indices created. The templates include both settings and mappings.

Secured by oauth_2_0 with scopes:
  • application:update

Analytics Security Facede supports OAuth 2.0 for authenticating all API requests.

URI Parameters

  • tenantID: required(string)

    Tenant ID.

    Example:

    ae14b8a3-e976-41db-b74c-73f12464b78c
  • applicationName: required(string)

    Application Name.

    Example:

    bspu4tiikfmmfgrk47jg

Body

Media type: application/json

Type: asf-api-types.TemplateRequest

Example:

{
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "serverTimestamp": {
        "type": "long"
      },
      "appName": {
        "type": "text",
        "fields": {
          "keyword": {
            "ignore_above": 256,
            "type": "keyword"
          }
        }
      },
      "endpointId": {
        "type": "text",
        "fields": {
          "keyword": {
            "ignore_above": 256,
            "type": "keyword"
          }
        }
      },
      "@version": {
        "type": "text",
        "fields": {
          "keyword": {
            "ignore_above": 256,
            "type": "keyword"
          }
        }
      },
      "tenantId": {
        "type": "text",
        "fields": {
          "keyword": {
            "ignore_above": 256,
            "type": "keyword"
          }
        }
      },
      "dataSample": {
        "properties": {
          "dv": {
            "properties": {
              "st": {
                "type": "long"
              },
              "id": {
                "type": "long"
              },
              "ts": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "ignore_above": 256,
                    "type": "keyword"
                  }
                }
              }
            }
          },
          "ms": {
            "properties": {
              "aq": {
                "type": "long"
              },
              "ps": {
                "properties": {
                  "2": {
                    "type": "long"
                  },
                  "10": {
                    "type": "long"
                  }
                }
              },
              "n2": {
                "type": "long"
              },
              "o3": {
                "type": "long"
              },
              "rh": {
                "type": "long"
              },
              "tp": {
                "type": "long"
              },
              "ts": {
                "type": "date"
              }
            }
          }
        }
      },
      "appVersionName": {
        "type": "text",
        "fields": {
          "keyword": {
            "ignore_above": 256,
            "type": "keyword"
          }
        }
      }
    }
  }
}

HTTP status code 200

Template created successfully.

Body

Media type: application/json

Type: asf-api-types.TemplateRequest

Example:

{
  "acknowledged": true
}

Secured by oauth_2_0

Headers

  • Authorization: optional (string)

    Used to send a valid OAuth 2 access token. Example: "Authorization: Bearer 'access_token'" where 'access_token' must be replaced by a valid OAuth access token. This header is needed only if API authentication is enabled for the service.

get /{tenantID}-{applicationName}/_template

Retrieve template.

Secured by oauth_2_0 with scopes:
  • application:read

Analytics Security Facede supports OAuth 2.0 for authenticating all API requests.

URI Parameters

  • tenantID: required(string)

    Tenant ID.

    Example:

    ae14b8a3-e976-41db-b74c-73f12464b78c
  • applicationName: required(string)

    Application Name.

    Example:

    bspu4tiikfmmfgrk47jg

HTTP status code 200

Template retrieved successfully.

Body

Media type: application/json

Type: asf-api-types.TemplateResponse

Example:

{
  "e02e0679-2de5-48af-a2f0-c650356dc739-bspu4tiikfmmfgrk47jg": {
    "order": 0,
    "index_patterns": [
      "e02e0679-2de5-48af-a2f0-c650356dc739-bspu4tiikfmmfgrk47jg-*"
    ],
    "settings": {},
    "mappings": {
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "serverTimestamp": {
          "type": "long"
        },
        "appName": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "endpointId": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "@version": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "tenantId": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        },
        "dataSample": {
          "properties": {
            "dv": {
              "properties": {
                "st": {
                  "type": "long"
                },
                "id": {
                  "type": "long"
                },
                "ts": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "ignore_above": 256,
                      "type": "keyword"
                    }
                  }
                }
              }
            },
            "ms": {
              "properties": {
                "aq": {
                  "type": "long"
                },
                "ps": {
                  "properties": {
                    "2": {
                      "type": "long"
                    },
                    "10": {
                      "type": "long"
                    }
                  }
                },
                "n2": {
                  "type": "long"
                },
                "o3": {
                  "type": "long"
                },
                "rh": {
                  "type": "long"
                },
                "tp": {
                  "type": "long"
                },
                "ts": {
                  "type": "date"
                }
              }
            }
          }
        },
        "appVersionName": {
          "type": "text",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        }
      }
    },
    "aliases": {}
  }
}

Secured by oauth_2_0

Headers

  • Authorization: optional (string)

    Used to send a valid OAuth 2 access token. Example: "Authorization: Bearer 'access_token'" where 'access_token' must be replaced by a valid OAuth access token. This header is needed only if API authentication is enabled for the service.

Mapping

Operations on mapping.

/{tenantID}-{applicationName}/_mapping get

get /{tenantID}-{applicationName}/_mapping

Secured by oauth_2_0 with scopes:
  • application:read

Analytics Security Facede supports OAuth 2.0 for authenticating all API requests.

URI Parameters

  • tenantID: required(string)

    Tenant ID.

    Example:

    ae14b8a3-e976-41db-b74c-73f12464b78c
  • applicationName: required(string)

    Application Name (can be without this also).

    Example:

    bspu4tiikfmmfgrk47jg

HTTP status code 200

Mapping retrieved successfully.

Body

Media type: application/json

Type: asf-api-types.RetrieveMapping

Example:

{
  "d6312fc1-4c5d-4d1d-8c8c-8ab16435b560-c1hod7irqa51r8l340ug-2021.07.04": {
    "mappings": {
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "@version": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "appName": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "appVersionName": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "dataSample": {
          "properties": {
            "dv": {
              "properties": {
                "id": {
                  "type": "long"
                },
                "st": {
                  "type": "long"
                },
                "ts": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                }
              }
            },
            "ms": {
              "properties": {
                "aq": {
                  "type": "long"
                },
                "n2": {
                  "type": "long"
                },
                "o3": {
                  "type": "long"
                },
                "ps": {
                  "properties": {
                    "10": {
                      "type": "long"
                    },
                    "2": {
                      "type": "long"
                    }
                  }
                },
                "rh": {
                  "type": "long"
                },
                "tp": {
                  "type": "long"
                },
                "ts": {
                  "type": "date"
                }
              }
            }
          }
        },
        "endpointId": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "serverTimestamp": {
          "type": "long"
        },
        "tenantId": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    }
  }
}

Secured by oauth_2_0

Headers

  • Authorization: optional (string)

    Used to send a valid OAuth 2 access token. Example: "Authorization: Bearer 'access_token'" where 'access_token' must be replaced by a valid OAuth access token. This header is needed only if API authentication is enabled for the service.

Msearch

Msearch documents.

/{tenantID}-{applicationName}-{date}/_msearch post

post /{tenantID}-{applicationName}-{date}/_msearch

The multi search API allows to execute several search requests within the same API.

URI Parameters

  • tenantID: required(string)

    Tenant ID.

    Example:

    ae14b8a3-e976-41db-b74c-73f12464b78c
  • applicationName: required(string)

    Application Name (can be without this also).

    Example:

    bspu4tiikfmmfgrk47jg
  • date: required(string)

    Date of the index (can be without this also).

    Example:

    14-12-2021

Body

Media type: application/json

Type: asf-api-types.MsearchRequest

Example:

{
  "query": {
    "match": {
      "message": "this is a test"
    }
  }
}

HTTP status code 200

Successfully made msearch request.

Body

Media type: application/json

Type: asf-api-types.MsearchResponse

Example:

{
  "took": 652,
  "timed_out": false,
  "_shards": {
    "total": 2,
    "successful": 2,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 10000,
      "relation": "gte"
    },
    "max_score": null,
    "hits": [
    ]
  }
}