Setting up and Configuring the Time Series Service

Time Series Service Setup

Like other Predix platform services, authentication for the Time Series service is controlled by the designated trusted issuer and is managed by the User Account and Authentication (UAA) web service. You must set up a UAA service instance as the trusted issuer before getting started with the Time Series service. For information about authentication and authorization in Predix services, see About Security Services.

Accounts

You should have the following accounts to use Predix services:

Software

SoftwareVersionDescription
Cloud Foundry CLILatest stable binary versionUse the Cloud Foundry CLI to deploy and manage applications and services. Download the latest stable binary from https://github.com/cloudfoundry/cli#downloads.
[AED1] (Optional) Java SE Development Kit (JDK)8

If you would like to use the Time Series Client Library, you will need Java 8. Download the JDK from

https://www.oracle.com/downloads/index.html.

(Optional) Maven If you would like to use the Time Series Client Library, you can use Maven to download that dependency. Other build tools like Gradle should work as well. You can download Maven from https://maven.apache.org/download.cgi.
Note: Git is not required to use the project. While you should be using some form of version control, the type of version control is up to you.

Task Roadmap

StepDescription
(Optional) Configure your proxy settings.Depending on your location and network configuration, you may need to configure your proxy settings to access remote resources. See t_defining_proxy_connections_to_remote_resources.html#task_97cc6304-e168-459d-9952-a45708ff8361.
(Optional) Update your Maven settings to use the Predix platform Artifactory.To use the Time Series Java client library, you need to include it in your project. See tss-using-client-lib.html#task_41133ec4-df51-4aed-98c6-6f054ac536cd.
(Optional) Deploy a Predix Hello World Web application.t_Deploying_an_App_to_Cloud_Foundry.html#task_xwn_lvb_vx.
Create a UAA client. See uaas-get-started.html#task_y1l_vms_2s.
Create the Time Series service instance.See tss-setup-configure.html#task_c75cfb23-550f-4395-8c11-428e77129b2c.
Bind your application to the service instance.See tss-setup-configure.html#task_fac802b9-5075-41dd-bd90-2a5bc261f998.
Create an OAuth client for the Time Series service.See uaas-managing-clients.html#task_79a81b74-552e-4f74-abfc-bd37e6adac87.
Update the OAuth2 client to use Time Series.See uaas-managing-clients.html#task_k3h_k2c_1x.
Add the required Time Series scopes.See tss-setup-configure.html#concept_1b5ecbe0-6b7e-4dc6-9c10-9ef973a7697c.
Add Predix zone token scopes to your application.See tss-setup-configure.html#task_9607e876-a349-40c5-9c0a-5cdd62d5e426.

Creating a UAA Service Instance

You can create multiple instances of the UAA service in your space.

About This Task

As a best practice, first delete any older unused instances before creating a new one.

Procedure

  1. Sign into your Predix account at https://www.predix.io.
  2. Navigate to Catalog > Services, then click the User Account and Authentication tile.
  3. Click Subscribe on the required plan.
  4. Complete the fields on the New Service Instance page.
    FieldDescription
    OrgSelect your organization.
    SpaceSelect the space for your application.
    Service instance nameEnter a unique name for this UAA service instance.
    Service planSelect a plan.
    Admin client secretEnter a client secret (this is the admin password for this UAA instance). The client secret can be any alphanumeric string.
    Note: Record the client secret in a secure place for later use.
    Subdomain(Optional) Enter a subdomain you might need to use in addition to the domain created for UAA. You must not add special characters in the name of the subdomain. The value of sub-domain is case-insensitive.
  5. Click Create Service.

Results

Your UAA instance is created with the following specifications:

  • A client identifier (admin).
    Note: An admin client is required for bootstrap purposes. You can create additional clients to use with your application.
  • A client secret (that you specified while creating the service).

To retrieve additional details of your instance, you can bind an application to your instance.

Using the Command Line to Create a UAA Service Instance

Optional procedure for using the command line instead of the graphical user interface to create a UAA service instance.

About This Task

You can create up to 10 instances of UAA service in your space. If you need additional instances, you must delete an older unused instance and create a new one.

Procedure

  1. Use the Cloud Foundry CLI to log into Cloud Foundry.
    cf login -a <API_Endpoint>
    Note: If you are a GE employee, you must use the cf login --sso command to log into Cloud Foundry. After you enter your SSO, you will receive a one-time passcode URL. Copy this URL and paste it in a browser to retrieve your one-time passcode. Use this code with the cf command to complete the CF login process.

    Depending on your Predix.io registration, the value of <API_Endpoint> is one of the following:

    • Predix US-West

      https://api.system.aws-usw02-pr.ice.predix.io

    • Predix Europe

      https://api.system.aws-eu-central-1-pr.ice.predix.io

    For example,

    cf login -a https://api.system.aws-usw02-pr.ice.predix.io
  2. List the services in the Cloud Foundry marketplace by entering the following command.
    cf marketplace

    The UAA service, predix-uaa, is listed as one of the available services.

  3. Create a UAA instance by entering the following command.
    cf create-service predix-uaa <plan> <my_uaa_instance> -c '{"adminClientSecret":"<my_secret>","subdomain":"<my_subdomain>"}'

    where:

    • cf stands for the CLI command, cloud foundry
    • cs stands for the CLI command create-service
    • <plan> is the plan associated with a service. For example, you can use the tiered plan for the predix-uaa service.
    • -c option is used to specify following additional parameters.
      • adminClientSecret specifies the client secret.
      • subdomain specifies a sub-domain you might need to use in addition to the domain created for UAA. This is an optional parameter. You must not add special characters in the name of the sub-domain. The value of sub-domain is case insensitive.
    Note: Cloud Foundry CLI syntax can differ between Windows and Linux operating systems. See the Cloud Foundry help for the appropriate syntax for your operating system. For example, to see help for the create service command, run cf cs.

Results

Your UAA instance is created with the following specification:

  • A client identifier (admin).

    Note: An admin client is created for bootstrap purposes. You can create additional clients to use with your application.
  • A client secret (that you specified while creating the service).

To retrieve additional details of your instance, you can bind an application to your instance.

Example

Create a predix-uaa service instance with client secret as admin and sub-domain as ge-digital:

cf cs predix-uaa tiered test-1 -c '{"adminClientSecret":"admin","subdomain":"ge-digital"}'

This is how it appears in VCAP SERVICES when using the cf env <app_name> command:

"VCAP_SERVICES": { 
"predix-uaa": [
   {
    "credentials": {
     "dashboardUrl": "https://uaa-dashboard.run.asv-pr.ice.predix.io/#/login/04187eb1-e0cf-4874-8218-9fb77a8b4ed9",
     "issuerId": "https://04187eb1-e0cf-4874-8218-9fb77a8b4ed9.predix-uaa.run.asv-pr.ice.predix.io/oauth/token",
     "subdomain": "04187eb1-e0cf-4874-8218-9fb77a8b4ed9",
     "uri": "https://04187eb1-e0cf-4874-8218-9fb77a8b4ed9.predix-uaa.run.asv-pr.ice.predix.io",
     "zone": {
      "http-header-name": "X-Identity-Zone-Id",
      "http-header-value": "04187eb1-e0cf-4874-8218-9fb77a8b4ed9"
     }
    },
    "label": "predix-uaa",
    "name": "testuaa",
    "plan": "Tiered",
    "provider": null,
    "syslog_drain_url": null,
    "tags": [],
    "volume_mounts": []
   }
  ],

Creating a Time Series Service Instance

Before You Begin

Complete the tasks in tss-setup-configure.html#reference_7ed111be-2b84-42c8-b8de-5d2a4f9bb799.

Note: If you are registered on the Predix Azure domain, you must use the command-line instructions to create your service.

Procedure

  1. Sign into your Predix account at https://www.predix.io.
  2. Navigate to Catalog > Data Management, and click the Time Series tile.
  3. Choose the plan, and click Subscribe.
  4. On the New Service Instance page, enter:
  5. (Optional) You can also use the Cloud Foundry CLI to create a Time Series service instance.
    Note: If you are a GE employee, you must use the cf login --sso command to log into Cloud Foundry. After you enter your SSO, you will receive a one-time passcode URL. Copy this URL and paste it in a browser to retrieve your one-time passcode. Use this code with the cf command to complete the CF login process.
    On Mac OS and Linux, use the following syntax:
    cf create-service predix-timeseries <plan> <my_time_series_instance> -c '{"trustedIssuerIds":["<uaa_instance1_host>/oauth/token", "<uaa_instance2_host>/oauth/token"]}'
      
    On Windows, use the following syntax:
    cf create-service predix-timeseries <plan> <my_time_series_instance> -c "{\"trustedIssuerIds\":[\"<uaa_instance1_host/oauth/token\", \"<uaa_instance2_host/oauth/token\"]}"
    where:
    • <plan> – The plan associated with a service.
    • <my_time_series_instance> – the service instance you are creating.
    • "trustedIssuerIds" – The issuer ID of your trusted issuer (UAA instance), such as https://13fa0384-9e2a-48e2-9d06-2c95a1f4f5ea.predix-uaa.grc-apps.svc.ice.ge.com/oauth/token. You can use a comma-separated list to specify multiple trusted issuers. You can retrieve this URL from the VCAP_SERVICES environment variable after you bind your UAA instance to an application.

What To Do Next

tss-setup-configure.html#task_fac802b9-5075-41dd-bd90-2a5bc261f998

Binding an Application to the Time Series Service Instance

About This Task

You must bind your application to the Time Series service instance to provision connection details and credentials for your Time Series service instance in the VCAP_SERVICES environment variable. Cloud Foundry runtime uses VCAP_SERVICES environment variables to communicate with a deployed application about its environment.

Procedure

  1. Bind your Time Series application to your service instance:
    cf bind-service <application_name> <my_time_series_instance>
  2. Restage your application to ensure the environment variable changes take effect:
    cf restage <application_name>
  3. To view the environment variables for your application, enter the following command:
    cf env <application_name>
    The command shows the environment variables, which contain your basic authorization credentials, client ID, and the ingestion and query endpoint URIs.
    {  
       "VCAP_SERVICES":{  
          "predix-timeseries":[  
             {  
                "credentials":{  
                   "ingest":{  
                      "uri":"wss://<ingestion_url>",
                      "zone-http-header-name":"Predix-Zone-Id",
                      "zone-http-header-value":"<Predix-Zone-Id>",
                      "zone-token-scopes":[  
                         "timeseries.zones.<Predix-Zone-Id>.user",
                         "timeseries.zones.<Predix-Zone-Id>.ingest"
                      ]
                   },
                   "query":{  
                      "uri":"https://<query_url>",
                      "zone-http-header-name":"Predix-Zone-Id",
                      "zone-http-header-value":"<Predix-Zone-Id>",
                      "zone-token-scopes":[  
                         "timeseries.zones.<Predix-Zone-Id>.user",
                         "timeseries.zones.<Predix-Zone-Id>.query"
                      ]
                   }
                },
                "label":"predix-timeseries",
                "name":"time-series-service-instance-predix-data-services",
                "plan":"beta",
                "tags":[  
                   "timeseries",
                   "time-series",
                   "time series"
                ]
             }
          ]
       }
    }

Creating an OAuth2 Client

You can create OAuth2 clients with specific permissions for your application to work with Predix Platform services. Often this is the first step after creating an instance of a service.

About This Task

When you create an instance of UAA, the UAA Dashboard is available for configuring that instance of UAA. You can use the Client Management tab in the UAA Dashboard to create the OAuth2 clients.

If you are prefer using the UAA command-line interface (UAAC) instead of UAA Dashboard to create an OAuth2 client, see uaas-managing-clients.html#task_sp2_zvk_rdb

Procedure

  1. In the Predix.io Console view, select the Space where your services are located.
  2. In the Services Instances page, select the UAA instance to configure.
  3. Select the Configure Service Instance option.
  4. In the UAA Dashboard login page, specify your admin client secret and click Login.
  5. In UAA Dashboard, select the Client Management tab.
    The Client Management tab has two views, Clients and Services . The Services view displays the service instances that you have created for your services.
    Note: The service instances displayed in the Services view were created while using the UAA that you are trying to configure. Service instances that you created using other UAA instances are not displayed on this page.
  6. Click Create Client to open the Create Client form.
  7. Complete the Create Client form.
    FieldDescription
    Client IDSpecify a name for the OAuth2 client you are creating.
    Authorized Grant TypesChoose one or more of the following grant types:
    • authorization_code

      When you use the authorization code grant type, the client directs the resource owner to UAA, which in turn directs the resource owner back to the client with the authorization code.

    • client_credentials

      When you use the client credentials grant type, the OAuth2 endpoint in UAA accepts the client ID and client secret and provides Access Tokens.

    • password

      When you use the resource owner password credentials grant type, the OAuth2 endpoint in UAA accepts the username and password and provides Access Tokens.

    • refresh_token

      The refresh tokens are credentials used to obtain access tokens. You can choose this option to obtain refresh token from UAA. You can then use the refresh token to obtain a new access token from UAA when the current access token becomes invalid or expires, or to obtain additional access tokens with identical or narrower scope.

    • implicit

      When you use the implicit grant type, UAA directly issues an Access Token to the client without authenticating the client. This reduces the number of round trips required to obtain an access token.

    For more information on grant types, see RFC 6749.

    Client SecretSpecify the password. It is important that you keep a note of this password. If lost, this password cannot be retrieved.
    Confirm Client SecretReenter the client secret.
    Redirect URISpecify a redirect URI to redirect the client after login or logout (for example, http://example-app.com/callback). Use this URI when you start using UAA as the service provider for your external Identity provider. UAA uses the value of Redirect URI for /oauth/authorize and /logout endpoints.

    You must specify a Redirect URI value if you use the Authorization Code or Implicit authorization grant type. When you use the Authorization Code grant type, the Redirect URI is your application's endpoint or callback that expects user authorization code. When you use the Implicit grant type, the Redirect URI is the end point where UAA sends the bearer token.

    Unique Resource Identifier consists of:
    • Access Protocol, http or https
    • Domain or IP address
    • Access Port such as 80 or 443
    • Path

    If you have a specific URL for your application callback, you can use that to set the Redirect URI value for the related client. For example, https://your-app-domain.run.aws-usw02-pr.ice.predix.io/path1/path2/callback.

    You can specify multiple values for Redirect URI as a list of allowed destinations that UAA server can redirect the users. For example, https://yourappdomain1.run.aws-usw02-pr.ice.predix.io/path1/path2/callback, https://yourappdomain2.run.aws-usw02-pr.ice.predix.io/path1/path2/callback.

    If the subdomain of your application is dynamic, you can set the value of Redirect URI using wilcards. For example, https://*.your-app-domain.run.aws-usw02-pr.ice.predix.io/path1/path2/callback.

    Note: You must only use ‘*’ for a domain that is exclusive to your application (Such as your-app-domain in example above). This prevents the redirect to be routed to an application that you do not own. You cannot use * in the top domain and sub domain (such as predix.io in the example above).
    ScopesScopes are permissions associated with an OAuth Client to determine user access to a resource through an application. The user permissions are for authorization grant types authorization_code, password and implicit.

    By default, the admin client is assigned all required scopes. For a new client, an administrator can select the scopes to be added based on client requirements.

    For a list of available scopes, see Scopes Authorized by the UAA.

    To use an OAuth2 client for your Predix Platform service instance, you must update your OAuth2 client to add scopes that are specific to each service after adding the client to the service instance.

    AuthoritiesAuthorities are permissions associated with the OAuth Client when an application or API is acting on its own behalf to access a resource with its own credentials, without user involvement. The permissions are for the client_credentials authorization grant type.

    By default, the admin client is assigned all required authorities. For a new client, an administrator can select the authorities to be added based on client requirements.

    The list of authorities matches the list of scopes. For a list of available UAA scopes, see Scopes Authorized by the UAA.

    To use an OAuth2 client for your Predix Platform service instance, you must update your OAuth2 client to add authorities that are specific to each service after adding the client to the service instance.

    Note: An admin client is not assigned the default authority to change the user password. To change the user password, you must add the uaa.admin authority to your admin client.
    Auto Approved ScopesSpecify scopes that can be approved automatically for the client without explicit approval from a resource owner.
    Allowed ProvidersSpecifies the names of the external identity providers, if any. This field is required if you are using external identity providers with UAA as a service provider.
    Access Token ValiditySpecifies the access-token expiration time in ms.
    Refresh Token ValiditySpecifies the refresh-token expiration time in ms.

What To Do Next

uaas-managing-clients.html#task_k3h_k2c_1x for your service specific information.

Updating the OAuth2 Client for Services

To use an OAuth2 client for secure access to your Predix Platform service instance from your application, you must update your OAuth2 client to add additional authorities or scopes that are specific to each service.

About This Task

To enable your application to access a platform service, your JSON Web Token (JWT) must contain the scopes required for a platform service. For example, some of the scope required for Access Control service are acs.policies.read acs.policies.write.

The OAuth2 client uses an authorization grant to request an access token. Based on the type of authorization grant that you have used, you must update your OAuth2 client to generate the required JWT. For more information on how the OAuth2 client is created, see Creating OAuth2 client.

If you use the UAA Dashboard to create additional clients, the client is created for the default client_credentials grant type. Some required authorities and scopes are automatically added to the client. You must add additional authorities or scopes that are specific to each service.

In addition, the admin client is not assigned the default authority to change the user password. To change the user password, you must add the uaa.admin authority to your admin client.

Use the following procedure to update the OAuth2 client.

Procedure

  1. In the Console view, select the Space where your services are located.
  2. In the Services Instances page, select the UAA instance to configure.
  3. Select the Configure Service Instance option.
  4. In the UAA Dashboard login page, specify your admin client secret and click Login.
  5. In UAA Dashboard, select the Client Management tab.
    The Client Management tab has two views, Clients and Services. The Services view displays the service instances that you have created for your services.
    Note: The service instances displayed in the Services view are the instances that you created using the UAA that you are trying to configure. The service instances that you created using some other UAA instance are not displayed on this page.
  6. Select the Switch to Services View option.
  7. In the Services view, select the service that you need to update.
  8. Choose an existing client or choose the Create a new client option. If you chose to create a new client, follow the steps in uaas-managing-clients.html#task_79a81b74-552e-4f74-abfc-bd37e6adac87.
  9. Click Submit.
  10. Click on the Switch to Clients View option.
  11. In the Clients view, click the edit icon corresponding to the client added in the previous step.
  12. Complete the Edit Client form.
    FieldDescription
    Authorized Grant TypesChoose one or more of the following grant types:
    • authorization_code

      When you use the authorization code grant type, the client directs the resource owner to UAA, which in turn directs the resource owner back to the client with the authorization code.

    • client_credentials

      When you use the client credentials grant type, the OAuth2 endpoint in UAA accepts the client ID and client secret and provides Access Tokens.

    • password

      When you use the resource owner password credentials grant type, the OAuth2 endpoint in UAA accepts the username and password and provides Access Tokens.

    • refresh_token

      The refresh tokens are credentials used to obtain access tokens. You can choose this option to obtain refresh token from UAA. You can then use the refresh token to obtain a new access token from UAA when the current access token becomes invalid or expires, or to obtain additional access tokens with identical or narrower scope.

    • implicit

      When you use the implicit grant type, UAA directly issues an Access Token to the client without authenticating the client. This reduces the number of round trips required to obtain an access token.

    For more information on grant types, see RFC 6749.

    Redirect URISpecify a redirect URI to redirect the client after login (for example, http://example-app.com/welcome).

    This URI is used when you start using UAA as service provider for your external Identify provider.

    ScopesBy default, the client is assigned a few required scopes. For a new client, an administrator can select the scopes to be added based on the selected grant type.

    If you select the authorization_code, password and implicit grant type, you must update the scopes with service specific scopes.

    For a complete list of required scopes, see uaas-managing-clients.html#reference_ec1_t3d_bx.

    For a list of available UAA scopes, see Scopes Authorized by the UAA.

    AuthoritiesBy default, the client is assigned a few required authorities. For a new client, an administrator can select the authorities to be added based on the selected grant type.

    If you select the client_credentials grant type, you must update the authorities with service specific authorities.

    For a complete list of scopes to be added for each service, see uaas-managing-clients.html#reference_ec1_t3d_bx.

    For a list of available UAA authorities, see Scopes Authorized by the UAA.

    Auto Approved ScopesSpecify scopes that can be approved automatically for the client without explicit approval from the resource owner.
    Allowed ProvidersSpecify the names of the external identity providers, if any. This field is required if you are using external identity providers with UAA as a service provider.
    Access Token ValiditySpecifies the access token expiration time in ms.
    Refresh Token ValiditySpecifies the refresh token expiration time in ms.

What To Do Next

You can complete the following additional tasks in UAA Dashboard:

If you have completed your OAuth2 client setup, you can bind your application to your service instance.

Authorities or Scopes Required for Time Series

When you create a new OAuth2 client, the client is assigned default scopes and authorities. You must add additional authorities or scopes that are specific to each service. To enable applications to access the Time Series service, your JSON Web Token (JWT) must contain the following Predix zone token scopes:
  • For ingestion requests:
    • timeseries.zones.<Predix-Zone-Id>.user
    • timeseries.zones.<Predix-Zone-Id>.ingest
  • For query requests:
    • timeseries.zones.<Predix-Zone-Id>.user
    • timeseries.zones.<Predix-Zone-Id>.query

The OAuth2 client uses an authorization grant to request an access token. OAuth2 defines four grant types. Based on the type of authorization grant that you use, you must update your OAuth2 client to generate the required JWT. For more information on how the OAuth2 client is created, see uaas-managing-clients.html#task_79a81b74-552e-4f74-abfc-bd37e6adac87.

Adding Zone Token Scopes to Applications

About This Task

The way you add zone token scopes depends on whether your application is a server-side or single-page web application.

Procedure

  1. To add zone token scopes to a server-side application:
    1. Create two OAuth clients (one for ingestion and one for querying) on any of the trusted issuers that were provided when you created the service instance.
    2. Add the zone-token-scopes from the VCAP credentials for the respective clients to their authorities.
      The below example shows ingestion zone-token-scopes from VCAP credentials:
      "zone-token-scopes":[  
                           "timeseries.zones.<Predix-Zone-Id>.user",
                           "timeseries.zones.<Predix-Zone-Id>.ingest"
                           "timeseries.zones.<Predix-Zone-Id>.delete" 
                        ]
      The below example shows query zone-token-scopes from VCAP credentials:
      "zone-token-scopes":[  
                           "timeseries.zones.<Predix-Zone-Id>.user",
                           "timeseries.zones.<Predix-Zone-Id>.query"
                           "timeseries.zones.<Predix-Zone-Id>.delete"
                        ]
  2. To add zone token scopes to a single-page web application that uses client-side JavaScript to consume the time-series service instance:
    1. Create two user groups for both data ingestion and querying.
    2. Add the user who needs access to the application to the appropriate groups for data ingestion and queries.
      For example, for data ingestion, create two groups with the following names:
      "timeseries.zones.<Predix-Zone-Id>.user"
      "timeseries.zones.<Predix-Zone-Id>.ingest"
    3. For users who query data, create two groups with the following names:
      "timeseries.zones.<Predix-Zone-Id>.user"
      "timeseries.zones.<Predix-Zone-Id>.query"
  3. You must also update your OAuth client scopes with the respective zone token scopes.
  4. Push your time-series data for streaming ingestion using the WebSocket protocol.