Control who can access which request traces and metrics in the AI Gateway.
Data Access Rules allow you to control who can access which request logs and metrics in the AI Gateway. Gateway Datasets provide access to subsets of traces and metrics by applying filters, enabling fine-grained access control based on users, teams, roles, and data scopes.
Data Access Rules let you specify which types of data each rule applies to:
Traces: Request logs and trace data from AI Gateway requests
Metrics: Aggregated metrics and monitoring data
You can select one or both data types. For example, you might create a rule that grants team data access for Metrics only (e.g., for dashboards) while restricting Traces access to own data for privacy.
Users can access all request logs and metrics across the entire organization, with optional filters to restrict access.Use cases:
Administrators managing organization-wide data
Cross-team analytics and reporting
Compliance and auditing requirements
Advanced Filters:When using all_data scope, you can optionally add filters to restrict access:
Metadata Filters: Filter by custom metadata keys from the X-TFY-METADATA header
Example: application_name IN (support-agent, ml-inference-server)
Created By Filters: Filter by who created the data
Example: created_by IN (team-1766965687056, user:john-doe)
SaaS gateway location metadata (tfy_gateway_region, tfy_gateway_zone) is also available in metadata and can be used in Data Access rule filters. See Metadata Keys.
Specifies which types of data the rule applies to. At least one must be selected.Available types:
Type
Description
traces
Request logs and trace data from AI Gateway
metrics
Aggregated metrics and monitoring data
Examples:
# Rule applies to both traces and metrics (default behavior)data_types: ["traces", "metrics"]# Rule applies to traces onlydata_types: ["traces"]# Rule applies to metrics onlydata_types: ["metrics"]
Click the delete icon (trash can) on a rule card to remove it. Default rules can also be deleted if needed.
Deleting a rule immediately revokes access for users who only had access through that rule. Make sure users have alternative access paths before deleting rules.
name: basic-data-access-configtype: gateway-data-access-configrules: # Allow specific user to access their own data - id: "alice-own-data" description: "Alice can access her own request logs" subjects: - "user:alice@example.com" data_types: ["traces", "metrics"] scope: "own_data" enabled: true # Allow team to access team data (metrics only for dashboards) - id: "engineering-team-data" description: "Engineering team can access team data" subjects: - "team:engineering" data_types: ["metrics"] scope: "team_data" enabled: true # Allow tenant admin to access all data - id: "admin-all-data" description: "Tenant admins can access all data" subjects: - "role:tenant-admin" data_types: ["traces", "metrics"] scope: "all_data" enabled: true
Filtered All Data Access
Rules with advanced filters to restrict all data access.
name: filtered-data-access-configtype: gateway-data-access-configrules: # Allow support team to access all data from support applications - id: "support-team-filtered-access" description: "Support team can access all support-related data" subjects: - "team:support" data_types: ["traces", "metrics"] scope: "all_data" filters: - field: metadata key: application_name operator: IN value: ["support-agent", "customer-chat"] enabled: true # Allow specific user to access data created by their team - id: "john-team-created-data" description: "John can access all data created by engineering team" subjects: - "user:john@example.com" data_types: ["traces", "metrics"] scope: "all_data" filters: - field: created_by operator: IN value: ["team:engineering"] enabled: true # Combined filters: metadata and created_by - id: "analytics-production-data" description: "Analytics team can access production data from specific apps" subjects: - "team:analytics" data_types: ["traces", "metrics"] scope: "all_data" filters: - field: metadata key: application_name operator: IN value: ["ml-inference-server", "data-pipeline"] - field: metadata key: environment operator: IN value: ["production"] enabled: true
When using metadata filters, ensure requests include the X-TFY-METADATA header with the relevant keys. For example:
Rules that apply to multiple users, teams, or roles.
name: multi-subject-data-access-configtype: gateway-data-access-configrules: # Multiple users accessing team data - id: "lead-engineers-team-data" description: "Lead engineers can access engineering team data" subjects: - "user:alice@example.com" - "user:bob@example.com" - "user:charlie@example.com" data_types: ["traces", "metrics"] scope: "team_data" enabled: true # Multiple teams accessing filtered all data - id: "teams-production-access" description: "Engineering and DevOps can access production data" subjects: - "team:engineering" - "team:devops" data_types: ["traces", "metrics"] scope: "all_data" filters: - field: metadata key: environment operator: IN value: ["production"] enabled: true
Virtual Account Access
Rules that include virtual account data through team_data scope.
name: virtual-account-data-access-configtype: gateway-data-access-configrules: # Team data automatically includes virtual accounts - id: "team-with-va-access" description: "Team can access their data including virtual accounts" subjects: - "team:engineering" data_types: ["traces", "metrics"] scope: "team_data" enabled: true # Specific virtual account access via created_by filter - id: "va-specific-access" description: "Access data created by specific virtual account" subjects: - "user:admin@example.com" data_types: ["traces", "metrics"] scope: "all_data" filters: - field: created_by operator: IN value: ["virtualaccount:acct_1234567890"] enabled: true
When using team_data scope, virtual accounts owned by the team are automatically included. No additional configuration needed.
Start with default rules: The default rules cover most common use cases. Only create custom rules when you need specific access patterns.
Use the most restrictive scope: Prefer own_data or team_data over all_data when possible. Only use all_data when necessary.
Restrict data types when appropriate: Use data_types to limit rules to only Traces or only Metrics when full access to both isn’t needed (e.g., metrics-only access for dashboard viewers).
Leverage filters: When using all_data, always add filters to restrict access to only what’s needed.
Document your rules: Use descriptive rule IDs and descriptions to make it clear what each rule does.
Test before disabling: Before disabling or deleting a rule, verify that users have alternative access paths.
Review regularly: Periodically review your data access rules to ensure they align with your organization’s access control policies.
Use roles for admin access: Prefer role:tenant-admin over individual users for administrative access to all data.