Hi, We're considering datahub for our metadata nee...
# getting-started
r
Hi, We're considering datahub for our metadata needs and I'm looking into various features we would need: • First of all, is it possible to deploy Datahub with postgres as the backend database? • Secondly, I can see that datahub itself is licensed under Apache 2.0; Can I assume the same applies also to any out-of-the-box connectors like Metabase, ClickHouse etc? • What options does Datahub provide for showing etl job status on a table? The use case is like this: we have ETL jobs that put data into tables. If the job fails or takes longer than expected, we want to be able to show on the table in the datahub UI that the data is stale/wrong/missing and we're working on it -- can we do that in a pretty way?
āœ… 1
c
Hi @rich-sandwich-70692, 1. Yes it is. There is a simple flag for it in the helm chart. Otherwise you can also use an existing Postgres instance or one that is managed differently. We chose Postgres in our deployment and so for it works like a charm. 2. All connectors are part of the datahub codebase which is licensed under the Apache 2.0 license. So yes the same license applies to the connectors 3. If you ingest metadata about your pipelines as well, then this is possible. We have set this up recently on our end and we can easily see if the pipeline run was successfull and how long it took. But I don't really know how easy it would be to get alerts when a pipeline runs longer than expected etc. Hope this helps šŸ™‚
r
It sure does, thank you!
@curved-planet-99787 would you be able to point in the right direction so I could configure pipeline metadata ingestion? We are using spark jobs for that purpose. Also, would it be possible to mock these for PoC stage? I don't want to spend a lot of time conferring with every single colleague about whether or not they think it's ok for me to connect a PoC to our production spark clusters šŸ˜…
c
Haha, well I can image šŸ˜… Here is the documentation for sending Spark metadata to DataHub: https://datahubproject.io/docs/metadata-integration/java/spark-lineage But for demo purposes you can simply ingest/create metadata via the API. Best way to do so is using the Python SDK (Java SDK is also available if preferred). A pipeline is represented by the Dataflow class, a pipeline step or task is represented as DataJob, and an execution of a pipeline as a DataProcessInstance.
r
I create the mock job, (see screenshot) and attached it to the table via Lineage, however I don't see any option of displaying the job status on the table ui. am I missing something?
It looks like your dataset in the screenshot has an additional tab in the top row, Operations, which mine does not (the last one is Validation)
c
Did you already create some executions via
DataProcessInstance
with a link to the corresponding job?
r
Yes, this is the code I was using
Copy code
import time
import uuid

from datahub.api.entities.corpgroup.corpgroup import CorpGroup
from datahub.api.entities.corpuser.corpuser import CorpUser
from datahub.api.entities.datajob.dataflow import DataFlow
from datahub.api.entities.datajob.datajob import DataJob
from datahub.api.entities.dataprocess.dataprocess_instance import (
    DataProcessInstance,
    InstanceRunResult,
)
from datahub.emitter.rest_emitter import DatahubRestEmitter

emitter = DatahubRestEmitter("<http://localhost:8080>")

jobFlow = DataFlow(env="prod", orchestrator="airflow", id="flow2")
jobFlow.emit(emitter)

# Flowurn as constructor
dataJob = DataJob(flow_urn=jobFlow.urn, id="job1", name="My Job 1")
dataJob.properties["custom_properties"] = "test"
dataJob.emit(emitter)

jobFlowRun: DataProcessInstance = DataProcessInstance(
    orchestrator="airflow", cluster="prod", id=f"{jobFlow.id}-{uuid.uuid4()}"
)
jobRun1: DataProcessInstance = DataProcessInstance(
    orchestrator="airflow",
    cluster="prod",
    id=f"{jobFlow.id}-{dataJob.id}-{uuid.uuid4()}",
)
jobRun1.parent_instance = jobFlowRun.urn
jobRun1.template_urn = dataJob.urn
jobRun1.emit_process_start(
    emitter=emitter, start_timestamp_millis=int(time.time() * 1000), emit_template=False
)
jobRun1.emit_process_end(
    emitter=emitter,
    end_timestamp_millis=int(time.time() * 1000),
    result=InstanceRunResult.FAILURE,
)
Also attaching the job runs in the UI
c
Haven't looked at your code in detail but based on the screenshot I'd assume that you haven't specified
inlets
and
outlets
, right?
r
No, I haven't. Are they a part of
Copy code
DataProcessInstance
? I didn't find any reference to them here: https://datahubproject.io/docs/generated/metamodel/entities/dataprocessinstance/#dataprocessinstancerunevent-timeseries
r
Should I do something like
Copy code
outlets=["urn:li:dataset:(urn:li:dataPlatform:clickhouse,GlobalLicenseServer.GlobalLicenseServer.license_usages,PROD)"]
?
c
Almost, in- and outlets parameter expects a List of
DatasetUrn
instances. So you could do the following:
Copy code
outlets=[DatasetUrn.create_from_string("urn:li:dataset:(urn:li:dataPlatform:clickhouse,GlobalLicenseServer.GlobalLicenseServer.license_usages,PROD)")]
r
Thanks! It's weird how when you pass a list of strings instead of a list of Urns you don't get an exception, it just works normally
I have this:
Copy code
jobFlowRun: DataProcessInstance = DataProcessInstance(
    orchestrator="airflow", cluster="prod", id=f"{jobFlow.id}-{uuid.uuid4()}",
    outlets=[DatasetUrn.create_from_string(
        "urn:li:dataset:(urn:li:dataPlatform:clickhouse,GlobalLicenseServer.GlobalLicenseServer.license_usages,PROD)")]
)
And the outlets still don't show up in the job run and "Operations" does not appear in the UI of the table I took the urn from the url of the table, perhaps that is not the way?
Also, according to the documentation, the parameter should be a list of strings
Copy code
inlets (List[str]): List of entities the DataProcessInstance consumes
outlets (List[str]): List of entities the DataProcessInstance produces
Sorry for getting on your case so much šŸ˜…
Although now I did run into some weirdness: somewhere between these scripts being ran, the job got removed the table's lineage, and even when I added it back it's not present in the Lineage table view, only in the visualization šŸ‘€
c
No worries, I'm glad to help šŸ™‚ Did you add the lineage manually?
r
Yeah I added it manually the ui
c
Okay, let me have a detailed look and I'll try to send you an example of our approach šŸ™‚