percona / mongodb_exporter

A Prometheus exporter for MongoDB including sharding, replication and storage engines
Apache License 2.0
1.18k stars 423 forks source link

cl_role is always "shardsvr" even for configsvr #320

Closed vishal-h closed 3 years ago

vishal-h commented 3 years ago

Shouldn't cl_role="configsvr" for config?

mongodb_configsvr{cl_id="some_id", cl_role="shardsvr", instance="host:port", job="mongo_exporter", rs_nm="cnf-serv", rs_state="1"}

I've setup a test-cluster using docker-compose.yml provided

percona-csalguero commented 3 years ago

Hi,

Currently the cluster_role is only showing if the node is master or not. That label get its value here

    nodeType, err := getNodeType(ctx, t.client)
    if err != nil {
        return errors.Wrap(err, "cannot get node type for topology info")
    }

and the function only returns 3 values:

func getNodeType(ctx context.Context, client *mongo.Client) (mongoDBNodeType, error) {
    md := proto.MasterDoc{}
    if err := client.Database("admin").RunCommand(ctx, primitive.M{"isMaster": 1}).Decode(&md); err != nil {
        return "", err
    }

    if md.SetName != nil || md.Hosts != nil {
        return typeShardServer, nil
    } else if md.Msg == typeIsDBGrid {
        // isdbgrid is always the msg value when calling isMaster on a mongos
        // see http://docs.mongodb.org/manual/core/sharded-cluster-query-router/
        return typeMongos, nil
    }

    return typeMongod, nil
}

I'm not sure if we should change this value. I've created a Jira ticket to ask our MongoDB experts and track the answers.

Thanks

denisok commented 3 years ago

fixed by #338 ?

percona-csalguero commented 3 years ago

Yes. I am closing this issue as it will be fixed by #338