Opserver
Opserver copied to clipboard
State and Votes columns in SQL dashboard are empty
I have WSFC clusters with multiple AG as resources. The following snippet is an example of my Opserver configuration:
{
"defaultConnectionString":"Application Name=opserver;Data Source=$ServerName$;Initial Catalog=master;User ID=USER;Password=PASS",
"clusters":[
{
"name":"P001 Cluster",
"nodes":[
{
"name":"P001-A" # listener
},
{
"name":"P001-B" # listener
},
{
"name":"P001-C" # listener
}
]
},
{
"name":"S001 Cluster",
"nodes":[
{
"name":"S001-A" # listener
},
{
"name":"S001-B" # listener
},
{
"name":"S001-C" # listener
}
]
}
]
}
But with the configuration described, I get the following result:
If go deeper into the source code, we will find the following code:
foreach (var m in state.Members)
{
m.IsLocal = string.Equals(m.MemberName, ServerProperties.Data?.ServerName, StringComparison.InvariantCultureIgnoreCase);
}
Something like that: {{machine}} == {{machine}}+{{instance}}. All elements will have the IsLocal property, evaluated to false.
The MemberName property of the AGClusterMemberInfo class is mapped to the member_name column:
SELECT member_name MemberName,
member_type Type,
member_state State,
number_of_quorum_votes Votes
FROM sys.dm_hadr_cluster_members;
Then the following method is called:
public AGClusterMemberInfo AGClusterMember =>
AGClusterInfo.Data?.Members.Find(c => c.IsLocal) ?? new AGClusterMemberInfo();
If the IsLocal property is false, the default object will be returned - State and Votes columns will are empty on SQL dashboard.
If I change the code above to:
foreach (var m in state.Members)
{
m.IsLocal = string.Equals(m.MemberName, ServerProperties.Data?.MachineName, StringComparison.InvariantCultureIgnoreCase);
}
Everything works fine, anyway for my configuration.
But I'm not sure about this approach. Maybe I misconfigured Opserver? Or is there really an mistake?
I think using named instances is expected, but using listeners also works, except for showing details by nodes in sql/servers in GetAvailabilityGroups.
@NickCraver, what do you think about using listeners with some limitation? I mean the availability of data only from primary replicas.
I added small changes in PR.
Before:
After:
Is it possible get feedback?