Connect with us

Tech

Multitenant Embedded Analytics: A Step-by-Step Guide

 


Lookers' built-in analytics capabilities help you drive business growth and generate new revenue streams by creating data-centric apps for your users and customers.

However, in a scenario where each client needs to track unique attributes such as “customer acquisition channel” or “contract renewal date”, one of the frequent challenges is to effectively manage custom attributes for dynamic fields defined by each client for enhanced data analysis.

Don't worry, this blog post will guide you through a practical step-by-step approach to implementing these dynamic fields, providing a smooth, scalable, and secure experience for all your users. By leveraging Looker's powerful features like groups, user attributes, and permissions, you can create a single dynamic model that adapts to each client's specific needs, without the need for cumbersome client-specific models.

Multi-tenant challenges

Let's be honest: key-value pairs alone are not enough for multi-tenant embedded analytics. You need a structured way to manage them.

Attribute visibility: Show users only the custom attributes that are relevant to your business, not all the clutter. Attribute naming: Make sure the names of these data fields match the definitions established within your application. Robust data security: Maintain privacy and trust by ensuring clients can only see and analyze their own data. Real-world example: Realizing the challenge

Let's illustrate this with a simple example. Consider an application where two customers have each configured custom attributes for a “User” entity, which is represented by the following column definitions:

entity_id: the entity the attribute belongs to. An application may define multiple entities (users, orders, etc.) and a customer who is defining a new attribute linked to one of them. customer_id: the application customer who set the attribute. attribute_type: the type of the attribute. attribute_id: the identifier for the attribute within the given attribute_type and customer_id. The key assumption is that attribute_ids are finite and are reused across multiple customers. attribute_name: the name the customer assigned to the attribute.

As you can see, each client defines a different number of attributes with different names and data types. Our goal is to design a Looker model that seamlessly accommodates these variations while allowing each client to see only the relevant data presented with consistent labels.

Now, let us assume that each customer has assigned values ​​to the custom attributes as shown in the following table, where entity_row_id represents the identifier for each entity (user_id, order_id, etc.). In this example, user 101 is Italian, has passport number 1234567890, became a customer in 2022, and plans to renew in 2026.

The solution: the power of groups, user attributes, and permissions

Our approach relies on effective data model design and leverages Looker's user management and access control features. Let's walk through the steps in detail.

1. Create a group

First, create separate Looker groups for each application customer, which allow you to assign custom values ​​and control both column configuration (labels, visibility) and row level security. Groups can be created and managed through the API.

2. Define user attributes

User attributes provide a customized experience for each Looker user. Attributes are used to control two LookML constructs:

Permissions (Visibility) Dimension Labels

In this example, we define two sets of user attributes for each entity.

The Access user attribute controls whether a user or user group can see a particular dimension.

Custom User Attributes Next, define the visibility of the group to reflect how each customer defined the first field of type string: The access user attribute is required for all customer defined entity_id, attribute_type, and attribute_id.

The Group Value Label user attribute controls the label that is displayed to a user or user group. For example:

Define the Label User Attribute Next, you can define group labels to reflect how each customer defined the first field of type string, as follows:

Defining group labels Please note that every customer defined entity_id, attribute_type, attribute_id must have a label user attribute.

We also define a user attribute named customer_id. Defining the customer_id User AttributeThis user attribute is used to model row-level security for each application customer. Adding a Group ValueUser attributes and group values ​​can be defined using the Looker API, so when a customer updates their definition in their application, the changes are propagated to Looker by updating the user attribute value.

3. Define permissions: Increase data security and isolation

Permissions are LookML constructs that are defined in model files and control access to other LookML constructs, ensuring that users in a particular client group can only see dimensions that are allowed for their profile.

For example, you can specify that any user with a user attribute access_user_date1 value of Yes meets the requirement and can access any LookML object (dimension, explorer, etc.) associated with the permission.

Access rights: access_user_date1 { user_attribute: acces_user_date1 allowed_values: [“Yes”]
}

Permissions must be defined for every entity_id, attribute_type, and attribute_id defined in the application.

4. Define your Looker view

For each entity, you define a Looker view that pivots the dynamic field data using a SQL-based persistent derived table (PDT), transforming the data into a columnar structure with each dynamic field represented in its own column, allowing greater flexibility in analysis and reporting.

In this example, we first filter the User entities, then pivot by attributes (identified by attribute_id and id). Note that this transformation does not take into account the attribute names defined by each customer.

view: user_attributes_pivoted { derived table: { sql: SELECT entity_row_id as user_id, customer_id, `STRING-1`, `STRING-2`, cast(`DATE-1` as DATE ) as `DATE-1`, cast(`DATE-2` as DATE ) as `DATE-2`, FROM ( select entity_row_id, customer_id, concat(attribute_type,'-',attribute_id) as attribute , atribute_value from `lookerprivateipfvi.flexible_attributes.attribute_value` WHERE entity_id = 'User' ) PIVOT (MAX(atribute_value) FOR attribute IN ('STRING-1','STRING-2','DATE-1', 'DATE-2')) ;; cluster_keys: [“entity_row_id”]

Datagroup trigger: dynamicattributes_default_datagroup }

The resulting pivot data looks like this:

Pivoted User Attributes

5. Define dimensions with dynamic labels and access

After you define the base view, you create two types of dimensions:

Customer-independent dimensions: These are fixed dimensions, such as user_id or customer_id, that are shared across all clients and are used to join data and implement row-level security. # user_id is the primary key that joins with the users table. dimension: user_id { type: number primary_key: yes hidden: yes sql: ${TABLE}.user_id ;; } # customer_id allows you to define row-level security on attributes. dimension: customer_id { type: number hidden: yes sql: ${TABLE}.customer_id ;; } Customer-dependent dimensions: These dimensions represent dynamic fields defined by each client. Use the LookML label and required required_access_grants parameters to dynamically control the dimension label and visibility based on previously defined user attributes and permissions.

In this example, we use a string dimension.

# Field corresponding to Attribute_type=STRING, Attribute_Id=2 Dimension: string2 { Label: “{{ _user_attributes[‘label_user_string2’] }}” Required permissions: [access_user_string2]
type: string sql: ${TABLE}.`STRING-2` ;; }

This dimension is labeled according to the user attribute label_user_string2 and is visible only to users who meet the access_user_string2 permission requirement.

If you use a date field instead, the dimension label will be read from the user attribute label_user_date1 and will only be visible to users who meet the access_user_date1 permission requirement. Note that advanced LookML features (such as time windows) can still be used.

# Fields corresponding to Attribute_type=DATE, Attribute_Id=1 dimension_group: date1 { label: “{{ _user_attributes[‘label_user_date1’] }}” Required permissions: [access_user_date1]
Type: Time Timeframe: [raw, date, week, month, quarter, year]
convert_tz: no datatype: date sql: ${TABLE}.`DATE-1` ;; } 6. Define a test exploration: Validate the setup

Next, you'll create a Looker Explore to test your dynamic model by switching between different client group profiles to verify that users only see relevant dimensions, properly labeled, and can filter based on custom fields.

In this example, we define a quest to ensure that the objective has been achieved.

explore: user_attributes_pivoted { # Row-level security access_filter: { field: customer_id user_attribute: customer_id } }

If you try to explore the model using the profile for Customer 1, you see the following dimensions and labels:

Fields that Customer 1 sees in Customer 2's profile are:

Fields that Customer 2 sees Notice that this time only two dimensions are displayed and they have been renamed as explained in the Customer 2 group. Thus, we have met our first set of requirements, as we have verified that it is possible to display different dimension names depending on the customer profile and hide unused dimensions.

Also, I would like to be able to create complex filters using custom fields. For example, for a user with a Customer 1 profile, I can define the following selection criteria: Filters that Customer 1 displays

7. Define a unified search

You can now build a Looker explorer that joins a base view (e.g. “User”) with the pivoted dynamic fields view, applying row-level security based on the customer_id user attribute to ensure data isolation.

explore: users { # Row level security access_filter: { field: user_attributes_pivoted.customer_id user_attribute: customer_id } # Join custom field views join: user_attributes_pivoted { sql_on: ${users.id}=${user_attributes_pivoted.user_id} ;; type: inner relationship: one_to_one } } 8. Explore and conquer.

This setup ensures that users from different clients see only the dynamic fields relevant to them, with consistent and meaningful labels, while maintaining strict data security. For a user with a Customer 1 profile, the following dimensions are displayed:

The dimensions viewed by Customer 1. These can be combined to define complex filters.

Define a complex filter for Customer 1

Conclusion

By leveraging the power of Looker groups, user attributes, and permissions, you can create flexible, scalable solutions that adapt to the unique needs of each client. This approach streamlines development, improves user experience, and keeps your applications secure and efficient.

Are you ready to level up your Looker game with dynamic fields?

Read our documentation, explore our APIs, and participate in our community forums to unlock the power of LookML for your multi-tenant applications.

resource:

Sources

1/ https://Google.com/

2/ https://www.googlecloudcommunity.com/gc/Community-Blogs/Multi-tenant-embedded-analytics-A-step-by-step-guide-to-managing/ba-p/755654

The mention sources can contact us to remove/changing this article

What Are The Main Benefits Of Comparing Car Insurance Quotes Online

LOS ANGELES, CA / ACCESSWIRE / June 24, 2020, / Compare-autoinsurance.Org has launched a new blog post that presents the main benefits of comparing multiple car insurance quotes. For more info and free online quotes, please visit https://compare-autoinsurance.Org/the-advantages-of-comparing-prices-with-car-insurance-quotes-online/ The modern society has numerous technological advantages. One important advantage is the speed at which information is sent and received. With the help of the internet, the shopping habits of many persons have drastically changed. The car insurance industry hasn't remained untouched by these changes. On the internet, drivers can compare insurance prices and find out which sellers have the best offers. View photos The advantages of comparing online car insurance quotes are the following: Online quotes can be obtained from anywhere and at any time. Unlike physical insurance agencies, websites don't have a specific schedule and they are available at any time. Drivers that have busy working schedules, can compare quotes from anywhere and at any time, even at midnight. Multiple choices. Almost all insurance providers, no matter if they are well-known brands or just local insurers, have an online presence. Online quotes will allow policyholders the chance to discover multiple insurance companies and check their prices. Drivers are no longer required to get quotes from just a few known insurance companies. Also, local and regional insurers can provide lower insurance rates for the same services. Accurate insurance estimates. Online quotes can only be accurate if the customers provide accurate and real info about their car models and driving history. Lying about past driving incidents can make the price estimates to be lower, but when dealing with an insurance company lying to them is useless. Usually, insurance companies will do research about a potential customer before granting him coverage. Online quotes can be sorted easily. Although drivers are recommended to not choose a policy just based on its price, drivers can easily sort quotes by insurance price. Using brokerage websites will allow drivers to get quotes from multiple insurers, thus making the comparison faster and easier. For additional info, money-saving tips, and free car insurance quotes, visit https://compare-autoinsurance.Org/ Compare-autoinsurance.Org is an online provider of life, home, health, and auto insurance quotes. This website is unique because it does not simply stick to one kind of insurance provider, but brings the clients the best deals from many different online insurance carriers. In this way, clients have access to offers from multiple carriers all in one place: this website. On this site, customers have access to quotes for insurance plans from various agencies, such as local or nationwide agencies, brand names insurance companies, etc. "Online quotes can easily help drivers obtain better car insurance deals. All they have to do is to complete an online form with accurate and real info, then compare prices", said Russell Rabichev, Marketing Director of Internet Marketing Company. CONTACT: Company Name: Internet Marketing CompanyPerson for contact Name: Gurgu CPhone Number: (818) 359-3898Email: [email protected]: https://compare-autoinsurance.Org/ SOURCE: Compare-autoinsurance.Org View source version on accesswire.Com:https://www.Accesswire.Com/595055/What-Are-The-Main-Benefits-Of-Comparing-Car-Insurance-Quotes-Online View photos

ExBUlletin

to request, modification Contact us at Here or [email protected]