I wish to set a limit of alerts from sensu. For instance, after 5 alerts from host X about disk capacity, I would like to stop receive alerts about the same issue.
Is it possible?
Thanks
You can do that with sensu filters.
Something like:
{
"filters": {
"firstfive": {
"attributes": {
"occurrences": "eval: value <= 5"
}
}
}
}
You need to add such filter to the handler you have created for the email.
Related
my $create_issue_json = '{"fields": { "project": { "key": "ABC" }, "summary": "summary for version 1", "description": "Creating an issue via REST API", "issuetype": { "name": "Minutes" }}}';
$tx1 = $jira_ua->post($url2 => json => decode_json($create_issue_json));
my $res1 = $tx1->res->body;
I try to create a jira issue of type Minutes but POST expects some fields which are not available in the issue of type Minutes. The below is the response.
{"errorMessages":["Brands: Brands is required.","Detection: Detection is required."],"errors":{"versions":"Affects Version/s is required.","components":"Component/s is required."}}
I also tried to fetch the schema using createMeta api but don't find any useful info. The below is the response from createmeta.
{"maxResults":50,"startAt":0,"total":3,"isLast":true,"values":[
{
"self":"https://some_url.com/rest/api/2/issuetype/1",
"id":"1",
"description":"A problem which impairs or prevents the functions of the product.",
"iconUrl":"https://some_url.com:8443/secure/viewavatar?size=xsmall&avatarId=25683&avatarType=issuetype",
"name":"Bug",
"subtask":false},
{
"self":"https://some_url.com:8443/rest/api/2/issuetype/12",
"id":"12",
"description":"An issue type to document minutes of meetings, telecons and the like",
"iconUrl":"https://some_url.com:8443/secure/viewavatar?size=xsmall&avatarId=28180&avatarType=issuetype",
"name":"Minutes",
"subtask":false
},
{
"self":"https://some_url.com:8443/rest/api/2/issuetype/23",
"id":"23",
"description":"Used to split an existing issue of type \"Bug\"",
"iconUrl":"https://some_url.com:8443/images/icons/cmts_SubBug.gif",
"name":"Sub Bug",
"subtask":true
}
]
}
It looks like there Jira Admin has added these as manadatory fields for all the issuetypes which I came to know after speaking with him. He has now individual configuration for different issue types and am able to create minutes.
I have a user(in Austria) who sent images of his account with the cloud being enabled, etc. However, when I did a request against his account, I couldn’t see any data -- its similar to what my US account showed.
For example, during this time period, he showed a run:
{"group":[ { "startTime":1611288803278, "endTime":1611893603278, "sampleSet":[ { "dataCollectorId":"derived:com.huawei.continuous.steps.delta:com.huawei.hwid:merged", "samplePoints":[ ] } ] }, { "startTime":1611288803278, "endTime":1611893603278, "sampleSet":[ { "dataCollectorId":"derived:com.huawei.continuous.distance.delta:com.huawei.hwid:merged", "samplePoints":[] } ] }, { "startTime":1611288803278, "endTime":1611893603278, "sampleSet":[ { "dataCollectorId":"derived:com.huawei.continuous.calories.burnt:com.huawei.hwid:merged", "samplePoints":[] } ] }, { "startTime":1611288803278, "endTime":1611893603278, "sampleSet":[ { "dataCollectorId":"derived:com.huawei.instantaneous.heart_rate:com.huawei.hwid:merged", "samplePoints":[] } ] } ] }
HTTP response header showed “HTTP/1.1 200 OK”and the value of the x-health-app-privacy field is 2.
Could you give any info for x-health-app-privacy?
Is Austria (Europe) a supported region? If so, is there any reason why I could not read the data from his account?
the value of the x-health-app-privacy field in the HTTP response header is 2, which means that the user did not authorize the Health Kit to get data in the Sports Health App. Please refer to the below screenshots for users how to enable authorization.
for x-health-app-privacy, pls refer to below. https://developer.huawei.com/consumer/en/doc/development/HMSCore-References-V5/latest- sampleset-0000001078273166-V5
ParameterTypeMandatory (M)/Optional (O)Description
I am fairly new to this but I need some help with my watcher setup. - I am using the X-Pack Watchers.
I have setup Heartbeat and I currently have 7 monitors.
i.e
monitor-01
monitor-02
etc.
I need help setting up my exact scenarios, I need help with 3 scenarios:
Scenario 1:
If monitor-01 goes offline, I want to send ONLY 1 email to "test#domain.com" with the body of: "Hello there, monitor-01 just went offline! Please check, thanks."
If monitor-02 goes offline, I want the exact same result as above.. I dont want multiple emails alerting me every second / minute if the monitor is down, I only want 1 email.
Scenario 2:
If monitor-01 or any my monitors are offline... Every 3 hours, I want a refresh email sent out (I would like the email body to contain how long the specific monitor is down for, i.e monitor down for 120hours 13 minutes). So, if 3 hours pass, I want to send an email to "test#domain.com" with the body of: "Hello there, this is a reminder email that monitor-01 is still offline! Please check, thanks."
Scenario 3:
If any of the monitors come back online, I want to send out an email to "test#domain.com" with the body of: "Hello there, great news! monitor-02 is back online. The monitor was down for 7hours 12 minutes. Thanks."
Can someone please assist? I looked everywhere and cannot find the correct syntax to create the above scenarios. These would be scenarios I feel could benefit other members of the community.
P.s, I currently have an advanced watch that I found in the forums but does not match my criteria. Here is the code for it:
{
"trigger": {
"schedule": {
"interval": "30s"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"heartbeat-*"
],
"rest_total_hits_as_int": true,
"body": {
"query": {
"bool": {
"must": {
"match": {
"monitor.status": "down"
}
},
"filter": {
"range": {
"#timestamp": {
"from": "now-50s"
}
}
}
}
},
"aggregations": {
"by_monitors": {
"terms": {
"field": "monitor.name"
}
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 0
}
}
},
"actions": {
"email_admin": {
"email": {
"profile": "standard",
"from": "noreply#domain.com",
"to": [
"test#domain.com"
],
"subject": "Monitor is DOWN: {{ctx.payload.aggregations.by_monitors.buckets.0.key}}",
"body": {
"text": "Hello, there is a monitor offline currently. Please check..."
}
}
}
}
}
The above script I put together sends an email every 30 seconds if a monitor is down which is not what I want.
Here is what the email says when everything is put together:
Subject: Monitor is DOWN: [UAT] Test Website
Body: Hello, there is a monitor offline currently. Please check...
Can someone assist with my scenarios? I spent days on this already.. many hours gone in, not much to come out from it!
Thanks.
There are two things you could look into: throttling and acknowledging notifications
throttling: once an action is done (eg sending an email), don't do that action again for 3 hours
acknowledge: : in this case you need to call the API to say: "I did receive the notification that watcher01 has found an error, don't send any notifications about it again."
I've recently upgraded from Sensu 0.24 to 1.2 and noticed that checks where triggered immediately to the referenced handlers.
On the old checks (with v0.24), checks had an "occurences" attribute to filter out noise. I only want checks to be handled by handlers on every n occurences, i.e. a http check must fail 5 times before the pagerduty handler will be triggered. This behaviour seems to have changed with the sensu upgrade.
As I understand, a handler is supposed to include a filter to sort out events based on attributes. So suppose this is my check:
{
"checks": {
"examplecom_http": {
"command": "check-http.rb --url https://example.com -s -k -q 'Keyword'",
"handlers": ["default","pagerduty"],
"subscribers": ["network"],
"interval": 60,
"occurrences": 5
}
}
}
In previous versions (or at least that was my understanding), this check would only be handled after 5 minutes (5 occurences for 60 second intervals) of failure. This doesn't work anymore, so now the handler should include a filter to handle occurences:
{
"handlers": {
"pagerduty": {
"type": "pipe",
"command": "/etc/sensu/plugins/pagerduty.rb",
"severities": ["critical"],
"filter": "occurences"
}
}
And the "occurences" filter would look like this:
{
"filters": {
"occurences": {
"attributes": {
"occurrences": "eval: value >= 5"
}
}
}
}
However, whatever comes after the eval part, be it value >= 5 or value < 5, the effect is the same and the pagerduty handler gets executed. I've tried using the negate directive with true and false but it seems my understanding of how filtering and occurences work for checks is just not correct. Maybe checks don't count their occurences at all?
Can somebody help and explain this?
As it stands right now, it looks like occurrences in your handlers JSON block is spelled incorrectly as occurences.
You will want "negate": false the way that your eval is currently written. When negate is false, this means that the handler will only trigger when the filter evaluation is true - negate will simply reverse the result so handlers trigger when the filter evaluation is false.
Finally, if you are looking to trigger the handler "every n occurrences" instead of every occurrence after the 5th, consider this evaluation:
{
"filters": {
"every_five": {
"attributes": {
"occurrences": "eval: value % 5 == 0"
}
}
}
}
This way, when the number of occurrences is divisible by 5, the handler will trigger, but you will need to add the every_five filter to your handler definition. You can change filter to filters and pass an array instead, like so:
{
"handlers": {
"pagerduty": {
"type": "pipe",
"command": "/etc/sensu/plugins/pagerduty.rb",
"severities": ["critical"],
"filters": [
"occurrences",
"every_five"
}
}
}
This will allow you to use the built-in filter "occurrences" as well as your custom filter.
I am using MongoDB for storing data in my application. I need to show the user how much data they filled using percentage.
For example: I have USER collection. In this collection i have several fields. Once the user enter data in their profile. I need to show how much percentage of data they filled in their profile.
In my application. I am using MongoDb and loopback frame work. I didn't defined any property in models.
How to solve this problem.Please help!!
You can add properties in you user model and define percentage against that or you can define one object property like the below mentioned
Suppose you have a User model and in it is settings property, of type object
Settings object will gave 10 keys. 1 keys is 10% then 10 keys filled is
100%. So just check whether user have filled the desired setting and mark a percentage.
so your model will be like
{
"name": "Member",
"base": "User",
"properties": {
"email": {
"type": "string"
},
"settings": {
"type": "object"
}
}
}
and inside your code retrieve the settings object and loop through it to make your percentage
Member.findById(your_id, function(err, usr){
if(!err){
var percentage_completed = 0;
Object.keys(usr.settings).map(function(pro){
if( usr.settings[pro] != "" ){
percentage_completed+=10;
}
})
}
})
I hope this will serve your purpose.