The stored procedures required to read or change the monitoring thresholds are the sp_replmontirohelppublicationthresholds and sp_replmonitorchangepublicationthreshold procedures.
To view the monitor threshold metrics for a publication
@publisher : the name of the publisher @publisher_db : the name of the published database @pbulication : the name of the publication @publication_type : 0 = transactional publication ................ 1 = snapshot publication ................ 2 = merge publication
To modify the monitor threshold metrics for a publication
@publisher : the name of the publisher @publisher_db : the name of the published database @pbulication : the name of the publication @publication_type : 0 = transactional publication ................ 1 = snapshot publication ................ 2 = merge publication @metric_id : 1 = expiration ................ 2 = latency ................ 4 = mergeexpiration ................ 5 = mergeslowrunduration ................ 6 = mergefastrunduration ................ 7 = mergefastrunspeed ................ 8 = mergeslowrunspeed @thresholdmetricname: the name of the publication threshold ................ (either this parameter or @metric_id is required) @value : the new metric value @shouldalert : generate alert (1=yes;0=no) @mode : monitoring mode (1=on;2=off)
Most settings that can't be done via sp_configure are registry based
So, you can use xp_instance_regread etc to change them. You'll have to find a list of registry keys yourself sorry but most are under HKLM\Software\Microsoft\Microsoft SQL Server
Update for resolution if someone is having similar situation.
I faced similar scenario where I could not get subscription agent list pulled up when launched replication monitor neither I could get the result from Sp_replmonitorhelpsubscription and the query kept on running without result. When checked currently executing query, all the distribution agent jobs were being blocked by couple of pull subscription distribution agent also causing issue for other distribution agents jobs and couldnot pull replicated commands. I stopped and restarted those 2 head blockers distribution agent jobs that released the rest of distribution agent jobs. This resolved the issue with subscription agents not being showed up on the replication monitor.
Best Answer
Detailed information about programmatically monitoring replications can be found on the official Microsoft Docs site:
Reference: Programmatically Monitor Replication
There is detailed information on all the stored procedures required to query monitoring details:
To monitor Publishers, publications, and subscriptions from the Distributor
To monitor transactional commands waiting to be applied at the Subscriber
To monitor merge changes waiting to be uploaded or downloaded
To monitor Merge Agent sessions
Answering your question
The stored procedures required to read or change the monitoring thresholds are the
sp_replmontirohelppublicationthresholds
andsp_replmonitorchangepublicationthreshold
procedures.To view the monitor threshold metrics for a publication
The parameters are:
@publisher : the name of the publisher
@publisher_db : the name of the published database
@pbulication : the name of the publication
@publication_type : 0 = transactional publication
................ 1 = snapshot publication
................ 2 = merge publication
To modify the monitor threshold metrics for a publication
The parameters are:
@publisher : the name of the publisher
@publisher_db : the name of the published database
@pbulication : the name of the publication
@publication_type : 0 = transactional publication
................ 1 = snapshot publication
................ 2 = merge publication
@metric_id : 1 = expiration
................ 2 = latency
................ 4 = mergeexpiration
................ 5 = mergeslowrunduration
................ 6 = mergefastrunduration
................ 7 = mergefastrunspeed
................ 8 = mergeslowrunspeed
@thresholdmetricname: the name of the publication threshold
................ (either this parameter or @metric_id is required)
@value : the new metric value
@shouldalert : generate alert (1=yes;0=no)
@mode : monitoring mode (1=on;2=off)