Пример #1
0
def _get_properties(rsp: Dict[Text, Any]) -> Iterable[CdProperty]:
    """ Retrieve key properties to be passed onto dynatrace server. """
    return [
        CdProperty("Topic", rsp.get("topic", "N/A")),
        CdProperty("Ack Deadline Seconds", rsp.get("ackDeadlineSeconds",
                                                   "N/A")),
    ]
def _get_properties(rsp: Dict[Text, Any]) -> Iterable[CdProperty]:
    """ Retrieve key properties to be passed onto dynatrace server. """
    return [
        CdProperty("Project", rsp.get("project", "N/A")),
        CdProperty("Connection Name", rsp.get("connectionName", "N/A")),
        CdProperty("Region", rsp.get("region", "N/A")),
        CdProperty("Pricing Tier", rsp.get("settings", {}).get("tier", "N/A"))
    ]
def _get_properties(rsp: Dict[Text, Any]) -> Iterable[CdProperty]:
    """ Retrieve key properties to be passed onto dynatrace server. """
    return [
        CdProperty("Status", rsp.get("status", "N/A")),
        CdProperty("Entry point", rsp.get("entryPoint", "N/A")),
        CdProperty("Available memory Mb", rsp.get("availableMemoryMb", "N/A")),
        CdProperty("Runtime", rsp.get("runtime", "")),
        CdProperty("Ingress settings", rsp.get("ingressSettings", "")),
    ]
def _get_properties(rsp: Dict[Text, Any]) -> Iterable[CdProperty]:
    """ Retrieve key properties to be passed onto dynatrace server. """
    machine_type = rsp.get("machineType", "/").split("/")[-1]
    labels = [CdProperty(label, value) for label, value in rsp.get("labels", {}).items()]
    return [
        *labels,
        CdProperty("Status", rsp.get("status", "N/A")),
        CdProperty("Cpu Platform", rsp.get("cpuPlatform", "N/A")),
        CdProperty("Machine Type", machine_type),
    ]
def test_flatten_and_enrich_metric_results_all_additional_dimensions():
    context_mock = MetricsContext(aiohttp.ClientSession(),
                                  aiohttp.ClientSession(), "", "",
                                  datetime.utcnow(), 0, "", "", False, False,
                                  None)
    metric_results = [[IngestLine("entity_id", "m1", "count", 1, 10000, [])]]
    entity_id_map = build_entity_id_map([[
        Entity("entity_id",
               "",
               "",
               ip_addresses=["1.1.1.1", "0.0.0.0"],
               listen_ports=[],
               favicon_url="",
               dtype="",
               properties=[CdProperty("Example property", "example_value")],
               tags=[],
               dns_names=["other.dns.name", "dns.name"])
    ]])

    lines = flatten_and_enrich_metric_results(
        context=context_mock,
        fetch_metric_results=metric_results,
        entity_id_map=entity_id_map)

    assert len(lines) == 1
    ingest_line = lines[0]
    expected_dimensions = [
        DimensionValue(name="entity.ip_address", value="0.0.0.0"),
        DimensionValue(name="entity.dns_name", value="dns.name"),
        DimensionValue(name="entity.example_property", value="example_value")
    ]
    assert set(expected_dimensions) == set(ingest_line.dimension_values)
Пример #6
0
def _get_properties(rsp: Dict[Text, Any]) -> Iterable[CdProperty]:
    """ Retrieve key properties to be passed onto dynatrace server. """
    return [
        CdProperty("State", rsp.get("state", "N/A")),
        CdProperty("Tier", rsp.get("tier", "N/A"))
    ]