Graph naming convertion

I’ve created an agent and I’m currently creating some graphs for my service through metrics.py

For the first graph to appear, i’ve used the following standard setup (and it works fine)

graph_MyService_state = Graph(
name=“MyService_state”,
title=Title(“Navigational Light State (NOT MONITORED=0, ON=1, OFF=2, FAIL=3)”),
minimal_range=MinimalRange(0, 4),
simple_lines=[
“Service_Metric1”,
“Service_Metric2”,
]
)

If i want to create a second graph for this service, what is the naming convention. Can i add it in to the declaration of the first graph? I have tried several combinations but cant get anything to appear

graph_MyService??? = Graph(

Yes, you would need a second Graph() definition for that. If you have already defined the metrics Service_Metric3 and Service_Metric4, you could define the graph with these two metrics like this:

graph_MyService_state = Graph(…)

graph_MyService_more_state = Graph(
    name="MyService_more_state",
    title=Title("Navigational Brighter Light State"),
    minimal_range=MinimalRange(0, 10),
    simple_lines=[
        "Service_Metric3",
        "Service_Metric4",
    ],
)

The variable name after the graph_ doesn’t really matter. You could also number all your graphs across all your self written plugins like this: graph_1, graph_2, graph_3 and so on, but I would not recommend that.
Just give them a name which describes what is shown and of which you think it doesn’t collide with already existing names. There’s no gurantee, though. Maybe use some sort of “namespace” (graph_rzrshp_state, graph_rzrshp_more_state, …).

Thanks for the reply. That worked super by declaring another Graph instance.

Do you know of any way to reference a metric in another service in the graph declaration. I want to compare two metrics side by side but they are in different services under the same host. The following wont work as is

graph_Nav_light_state_compare = Bidirectional(
    name="graph_Nav_light_compare",
        title=Title("Light status Vs Voltage"),
        lower=Graph(
            name="lower",
            title=Title("Voltage"),
            compound_lines=["Station_Battery_1"] #this metric is in another service
    ),
        upper=Graph(
            name="upper",
            title=Title("Navigational light"),
            compound_lines=["Nav_light_ON"]
    )
)

No, I’m afraid I do not know how to achieve that.

Beside @Dirk’s remarks i would say it is not possible to build a graph from two different services with the graphing system automatically.

The only way would be the “Custom graph” feature only available inside the Enterprise edition and up.

Really appreciate the input. At this stage i think we can close the call. Just have to convince our users they don’t need the comparison :slight_smile: