:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
from typing import Optional, cast
from products.warehouse_sources.sources.appdynamics._config import AppdynamicsSourceConfig
from products.warehouse_sources.sources.appdynamics.appdynamics import (
OAUTH_FAILED_MESSAGE,
AppdynamicsAuth,
AppdynamicsResumeConfig,
appdynamics_source,
validate_credentials as validate_appdynamics_credentials,
)
from products.warehouse_sources.sources.appdynamics.settings import (
APPDYNAMICS_ENDPOINTS,
DEFAULT_EVENT_TYPES,
DEFAULT_METRIC_PATHS,
ENDPOINTS,
INCREMENTAL_FIELDS,
MAX_EVENT_TYPES,
MAX_METRIC_PATHS,
)
from products.warehouse_sources.sources.sdk import (
CanonicalDescriptions,
DataWarehouseSourceCategory,
ExternalDataSourceType,
FieldType,
ReleaseStatus,
ResumableSource,
ResumableSourceManager,
SourceConfig,
SourceFieldInputConfig,
SourceFieldInputConfigType,
SourceFieldSelectConfig,
SourceFieldSelectConfigOption,
SourceInputs,
SourceRegistry,
SourceResponse,
SourceSchema,
detect,
)
@SourceRegistry.register
class AppdynamicsSource(ResumableSource[AppdynamicsSourceConfig, AppdynamicsResumeConfig]):
codebase_detection = detect(
env=("^APPDYNAMICS_",),
script_hosts=("cdn.appdynamics.com",),
npm=("appdynamics", "@appdynamics/react-native-agent"),
pypi=("appdynamics",),
cocoapods=("AppDynamicsAgent",),
maven=(
"com.appdynamics:appdynamics-runtime",
"com.appdynamics:appdynamics-gradle-plugin",
"com.appdynamics:appdynamics-injector",
"com.appdynamics:appdynamics-kotlin-compiler-plugin",
"com.appdynamics:appdynamics-maven-plugin",
"com.appdynamics:appdynamics-native-crash-handler",
),
pub=("appdynamics_agent",),
)
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.APPDYNAMICS
@property
def connection_host_fields(self) -> list[str]:
# Every credential is qualified as `<user-or-client>@{account_name}`, so retargeting
# `account_name` sends the preserved secret to a different account — require re-entry.
return ["account_name"]
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.APPDYNAMICS,
category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,
label="Splunk AppDynamics (Cisco)",
releaseStatus=ReleaseStatus.BETA,
keywords=["appdynamics", "cisco", "splunk", "apm"],
caption="""Sync your Splunk AppDynamics (Cisco) APM data (applications, business transactions, tiers, nodes, backends, events, transaction snapshots, health rules, health rule violations, anomalies, metric paths, metric time series, and monitored database servers) into the PostHog Data warehouse.
Enter your controller URL (e.g. `https://mycompany.saas.appdynamics.com`) and your account name, then authenticate with an OAuth API client (recommended) or a username and password.
You can create an API client in your controller under **Administration → API Clients**. The API client (or user) needs read access to the applications you want to sync. If your account signs in via Cisco Identity Provider, basic authentication is disabled and an API client is required.""",
iconPath="/static/services/appdynamics.png",
docsUrl="https://posthog.com/docs/cdp/sources/appdynamics",
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="host",
label="Controller URL",
type=SourceFieldInputConfigType.TEXT,
required=True,
placeholder="https://mycompany.saas.appdynamics.com",
secret=False,
),
SourceFieldInputConfig(
name="account_name",
label="Account name",
type=SourceFieldInputConfigType.TEXT,
required=True,
placeholder="mycompany",
secret=False,
),
SourceFieldSelectConfig(
name="auth_method",
label="Authentication method",
required=True,
defaultValue="api_client",
options=[
SourceFieldSelectConfigOption(
label="OAuth API client",
value="api_client",
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="api_client_name",
label="API client name",
type=SourceFieldInputConfigType.TEXT,
required=False,
placeholder="posthog-import",
secret=False,
),
SourceFieldInputConfig(
name="api_client_secret",
label="Client secret",
type=SourceFieldInputConfigType.PASSWORD,
required=False,
placeholder="",
secret=True,
),
],
),
),
SourceFieldSelectConfigOption(
label="Username and password",
value="basic",
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="username",
label="Username",
type=SourceFieldInputConfigType.TEXT,
required=False,
placeholder="",
secret=False,
),
SourceFieldInputConfig(
name="password",
label="Password",
type=SourceFieldInputConfigType.PASSWORD,
required=False,
placeholder="",
secret=True,
),
],
),
),
],
),
SourceFieldInputConfig(
name="metric_paths",
sync_setting=True,
label="Metric paths (one per line)",
type=SourceFieldInputConfigType.TEXTAREA,
required=False,
placeholder="Overall Application Performance|*",
secret=False,
),
SourceFieldInputConfig(
name="event_types",
sync_setting=True,
label="Event types (one per line)",
type=SourceFieldInputConfigType.TEXTAREA,
required=False,
placeholder="APPLICATION_DEPLOYMENT",
secret=False,
),
],
),
)
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.appdynamics.canonical_descriptions import CANONICAL_DESCRIPTIONS
return CANONICAL_DESCRIPTIONS
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
"401 Client Error": "Your AppDynamics credentials are invalid or expired. Please update your credentials and reconnect.",
"403 Client Error": "Your AppDynamics user or API client is missing read access to application data. Grant the required roles and try again.",
OAUTH_FAILED_MESSAGE: "Your AppDynamics API client credentials were rejected. Check your API client name, client secret, and account name, then reconnect.",
"Too many metric paths configured": None,
"Too many event types configured": None,
"Too many AppDynamics applications": None,
"AppDynamics sync would issue": None,
}
def _auth_for_config(self, config: AppdynamicsSourceConfig) -> AppdynamicsAuth:
if config.auth_method.selection == "basic":
if not config.auth_method.username or not config.auth_method.password:
raise ValueError("Missing AppDynamics username or password")
return AppdynamicsAuth(
account_name=config.account_name,
username=config.auth_method.username,
password=config.auth_method.password,
)
if not config.auth_method.api_client_name or not config.auth_method.api_client_secret:
raise ValueError("Missing AppDynamics API client name or client secret")
return AppdynamicsAuth(
account_name=config.account_name,
api_client_name=config.auth_method.api_client_name,
api_client_secret=config.auth_method.api_client_secret,
)
def _metric_paths_for_config(self, config: AppdynamicsSourceConfig) -> list[str]:
paths: list[str] = [line.strip() for line in (config.metric_paths or "").splitlines() if line.strip()]
if len(paths) > MAX_METRIC_PATHS:
raise ValueError(
f"Too many metric paths configured ({len(paths)}); the maximum is {MAX_METRIC_PATHS}. "
"Use wildcard paths to cover more metrics with fewer entries."
)
return paths or list(DEFAULT_METRIC_PATHS)
def _event_types_for_config(self, config: AppdynamicsSourceConfig) -> list[str]:
types: list[str] = [line.strip() for line in (config.event_types or "").splitlines() if line.strip()]
if len(types) > MAX_EVENT_TYPES:
raise ValueError(f"Too many event types configured ({len(types)}); the maximum is {MAX_EVENT_TYPES}.")
return types or list(DEFAULT_EVENT_TYPES)
def get_schemas(
self,
config: AppdynamicsSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
schemas = [
SourceSchema(
name=endpoint,
supports_incremental=bool(INCREMENTAL_FIELDS.get(endpoint)),
supports_append=bool(INCREMENTAL_FIELDS.get(endpoint)),
incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),
description=APPDYNAMICS_ENDPOINTS[endpoint].description,
)
for endpoint in ENDPOINTS
]
if names is not None:
names_set = set(names)
schemas = [s for s in schemas if s.name in names_set]
return schemas
def validate_credentials(
self,
config: AppdynamicsSourceConfig,
team_id: int,
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
try:
auth = self._auth_for_config(config)
self._metric_paths_for_config(config)
self._event_types_for_config(config)
except ValueError as exc:
return False, str(exc)
return validate_appdynamics_credentials(config.host, auth, team_id, schema_name=schema_name)
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[AppdynamicsResumeConfig]:
return ResumableSourceManager[AppdynamicsResumeConfig](inputs, AppdynamicsResumeConfig)
def source_for_pipeline(
self,
config: AppdynamicsSourceConfig,
resumable_source_manager: ResumableSourceManager[AppdynamicsResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return appdynamics_source(
host=config.host,
auth=self._auth_for_config(config),
endpoint=inputs.schema_name,
logger=inputs.logger,
resumable_source_manager=resumable_source_manager,
team_id=inputs.team_id,
metric_paths=self._metric_paths_for_config(config),
event_types=self._event_types_for_config(config),
should_use_incremental_field=inputs.should_use_incremental_field,
db_incremental_field_last_value=inputs.db_incremental_field_last_value
if inputs.should_use_incremental_field
else None,
)