Yelp / elastalert

Easy & Flexible Alerting With ElasticSearch
https://elastalert.readthedocs.org
Apache License 2.0
7.97k stars 1.74k forks source link

Project dependencies may have API risk issues #3262

Closed PyDeps closed 1 year ago

PyDeps commented 1 year ago

Hi, In elastalert, inappropriate dependency versioning constraints can cause risks.

Below are the dependencies and version constraints that the project is using

apscheduler>=3.3.0
aws-requests-auth>=0.3.0
blist>=1.3.6
boto3>=1.4.4
cffi>=1.11.5
configparser>=3.5.0
croniter>=0.3.16
elasticsearch>=7.0.0
envparse>=0.2.0
exotel>=0.1.3
jira>=1.0.10<1.0.15
jsonschema>=3.0.2
mock>=2.0.0
prison>=0.1.2
py-zabbix==1.1.3
PyStaticConfiguration>=0.10.3
python-dateutil>=2.6.0<2.7.0
PyYAML>=5.1
requests>=2.0.0
stomp.py>=4.1.17
texttable>=0.8.8
twilio==6.0.0

The version constraint == will introduce the risk of dependency conflicts because the scope of dependencies is too strict. The version constraint No Upper Bound and * will introduce the risk of the missing API Error because the latest version of the dependencies may remove some APIs.

After further analysis, in this project, The version constraint of dependency elasticsearch can be changed to >=0.4.1,<=1.0.0.

The above modification suggestions can reduce the dependency conflicts as much as possible, and introduce the latest version as much as possible without calling Error in the projects.

The invocation of the current project includes all the following methods.

The calling methods from the elasticsearch
elasticsearch.helpers.reindex
The calling methods from the all methods
f_query.replace
self.ref_windows.setdefault
self.es_version.split
self.next_alert_time
self.crossed_thresholds
clock
dashboard.get
self.client.fields
jira_field.startswith
os.path.dirname
self._ensure_new_line
os.path.isabs
self.PagerTreeAlerter.super.__init__
self.occurrences.setdefault
self.get_index
BasicMatchString
start.utcoffset
kibana.set_time
res.get
self.get_json_payload
alert.pop
term.endswith
logging.config.dictConfig
self.rules.remove
query_element.update
Exception
dict
self.use_kibana_link
body.split.x.x.join.format.replace
sns_client.publish
formatted_list.append
card.append
artifacts.append
float
ZabbixMetric
self.create_card
self.aggregated_metrics.append
self.parse_args
add_suffix.startswith
self.SlackAlerter.super.get_aggregation_summary_text__maximum_width
tracer.setLevel
kibana.set_included_fields
item.replace
entry.startswith
self.generate_aggregation_query
format_index
defaults.items
self.HTTPPostAlerter.super.__init__
seconds
es_filter.get
dt.replace
self.SlackAlerter.super.__init__
field.self.seen_values.append
self.unwrap_interval_buckets
elastalert_logger.info
unix_to_dt
query_template.append
responders_values.items
formated_responders.append
term.startswith
alert_text.encode
filename.endswith
self.GitterAlerter.super.__init__
rule.matches.pop
find_packages
names.append
self.adjust_deprecated_values
self.thread_data.current_es.clear_scroll
text_table.draw
email_msg.as_string
alerter.alert
exit
input
self.get_disabled_rules
get_module
e.str.EAException.with_traceback
r.raise_for_status
hashlib.sha1
row.get
self.StrideAlerter.super.__init__
key.find
headers.update
read_es_index_mapping
create_index_mappings
start.strftime
sys.exc_info
title.replace
filters.append
ElastAlerter
client.start
self.match.items
format
writeback_body.keys
self.get_hits_terms
load_conf
client.messages.create
kibana_filter.update
boto3.Session
self.adjust_start_time_for_overlapping_agg_query
self.NewTermsRule.super.__init__
fh.read
match_data_key.format
re.findall
logging.warn
results.append
rule_inst.add_count_data
rules_loader_class
hit.setdefault
next
original_start.strftime
end.utcoffset
is_atleastsix
self.create_custom_title
match_items.sort
self.handle_event
self.find_matches
self.ZabbixAlerter.super.__init__
json.dumps
self.data.remove
self.get_top_counts
frozenset
identifier.f.replace
env
self.data.add
round
qk.self.cur_windows.mean
self.generate_kibana4_db
datetime.strptime
processed_hits.append
self.LineNotifyAlerter.super.__init__
self.ServiceNowAlerter.super.__init__
self.smtp.quit
self.rule.get.items
ticket.fields.labels.append
self.first_event.pop
self.thread_data.current_es.deprecated_search
alerts.append
is_atleastsixtwo
start.date
index.find
self.find_existing_ticket
subp.wait
self.comment_on_ticket
self.base_config.items
self.BaseAggregationRule.super.__init__
os.path.abspath
zip
placeholder.update
self.create_footer
self.rule_schema.validate
e.rule.EAException.with_traceback
conn.connect
self.get_ts.self.rules.EventWindow.bucket.self.occurrences.setdefault.append
self.occurrences.items
self.writeback_es.ping
max
sphinx_rtd_theme.get_html_theme_path
rule.setdefault
response.raise_for_status
self.writeback_es.is_atleastsixsix
dt.strftime
self.rules
self.run_query
qk.append
element.format
self.get_aggregation_query
self.onRemoved
dir
signal.signal
query.append
SMTP_SSL
self.get_aggregated_matches
self.check_for_match
formatdate
self.SlackAlerter.super.get_aggregation_summary_text
self.handle_config_change
self.format_body
repr
total_seconds
self.send_notification_email
remove.append
self._add_match_items
self.create_header
kibana.set_timestamp_field
parse_deadline
email.as_string
self.alerts_mapping.get
self.get_aggregation_key_value
self.get_alert_body
dashboard.append
self.alias.format
uuid.uuid4
self.SpikeRule.super.add_match
self.import_rules.get
dt_to_ts_with_format
logging.FileHandler
self.resolve_rule_references
self.is_yaml
match_enhancements.append
self.is_silenced
self.load_alerts
body.split
reversed
self.check_matches
print
self.max_age.datetime.timedelta.datetime.datetime.now.strftime
self.writeback_es.is_atleastsixtwo
dct.items
os.listdir
extra_info.items
self.es_clients.pop
self.smtp.ehlo
random.randint
self.adjust_start_time_for_interval_sync
BackgroundScheduler
main
os.getcwd
string.format
json.JSONEncoder.default
build_es_conn_config
self.send_alert
e.repr.EAException.with_traceback
self.load_configuration
rule.keys
self.es_clients.setdefault
enhancement.process
root.copy.items
self.disabled_rules.remove
ret.update
datetime.datetime.strptime
re.split
ts_to_dt
matches.append
valid_matches.append
self.get_names
self.zbx_sender_port.self.zbx_sender_host.ZabbixSender.send
set_es_key
self.get_details
data.get
env_settings.items
EAException.with_traceback
IndicesClient
field.endswith
self.occurrences.keys
self.rules_loader.load_configuration
self.first_event.get
self.SnsAlerter.super.__init__
self.jira_args.pop
self.get_hits
self.reset_rule_schedule
self.seen_values.items
self.writeback_es.search
payload.update
query_key.split
rule_inst.add_aggregation_data
self.percentage_violation
self.rules_loader.load
kibana.kibana4_dashboard_link
mapping.items
self.transition_ticket
str
connection_details.get
globals
enumerate
alert_text.format
self.get_dashboard
elasticsearch_client
self.thread_data.current_es.count
obj.isoformat
body.replace
self.HipChatAlerter.super.create_alert_body
cf_value.format
sorted
json.loads
self.es.info
self.writeback_es.deprecated_search
rule.endswith
self.init_rule
query.update
new_rule.get
list
JIRA
self.wait_until_responsive
requests.urllib3.disable_warnings
map
conf.setdefault
new_rule.total_seconds
x.startswith
self.set_jira_arg
client.sms
self.get_rule_file_hash
kibana.set_name
self.load_options
ts_to_dt_with_format
hasattr
self.pagerduty_incident_key.format
dateutil.parser.parse
res.get.get
os.path.expandvars
conn.start
data.items
logging.warning
self.get_all_terms
self.create_default_title
self.priority_ids.keys
self.remove_duplicate_events
key.format
self.FlatlineRule.super.__init__
opsgenie_subject.format
create_alert
self.custom_message.format
strValue.startswith
self.deferred_settings.append
additional_terms.append
app_filters.append
datetime.datetime.now.strftime
self.cardinality_cache.items
self.client.add_comment
rule_es.is_atleastfive
query_element.pop
self.get_hits_count
kibana7_disover_global_state
dateutil.tz.tzlocal
self.HipChatAlerter.super.__init__
es_filter.keys
self.MattermostAlerter.super.get_aggregation_summary_text__maximum_width
configure_logging
self.is_atleastsix
stomp.Connection
new_events.append
ts_now
_find_es_dict_by_key
es_filter.items
self.es.search
d.utcoffset
event.update
logging.getLogger.setLevel
self.add_aggregated_alert
self.MattermostAlerter.super.__init__
self.resolve_rule_reference
qk.self.ref_windows.mean
resolve_string
rule.get
match.datetime.strptime.strftime
self._add_custom_alert_text
self.remove_old_events
ts.replace.replace
pretty_ts
es_version.split
self.get_aggregation_summary_text__maximum_width
config_filters.append
self.filters_from_kibana
input.lower
value_str.replace
sys.exit
self.thread_data.current_es.is_atleastseven
self.silence_cache.keys
next_run.replace
self.is_five_or_above
self.load_modules
self.reset_jira_args
self.handle_pending_alerts
self.create_title
tuple
parser.add_argument
self.CardinalityRule.super.__init__
self.smtp.sendmail
qk.split
self.scheduler.add_job
elasticsearch.helpers.reindex
self.opsgenie_details.items
alert_config_value.items
self.writeback_es.delete
rule.pop
rule.items
rule
filters_from_dashboard
alert_subject.format
self.scheduler.pause_job
self.writeback
counts.items
self.MattermostAlerter.super.get_aggregation_summary_text
self.cardinality_cache.setdefault
context.keys
RefeshableAWSRequestsAuth
datetime.datetime
JiraFormattedMatchString
self.rules.append
os.walk
self.sleep_for
HTTPProxyAuth
self.get_named_key_value
range
session.client
job.modify
es_index.create
self.SpikeRule.super.__init__
zm.append
self.FrequencyRule.super.__init__
logging.debug
self.change_map.get
self.duration
self._pretty_print_as_json
responder.format
KeyError
module_name.rsplit
join
ex.watcher.format.Exception.with_traceback
__import__
params.pop
copy.deepcopy
self.send_pending_alerts
lookup_field.self.seen_values.append
qk.self.ref_windows.clear
lookup_es_key
qk.self.cardinality_cache.pop
overwrites.items
self.TwilioAlerter.super.__init__
min
self.scheduler.remove_job
dt.tzinfo.tzname
datetime.datetime.utcnow
sub_term.split
key.startswith
rule_conf.get
EventWindow
self.check_matches_recursive
int
parser.feed
subprocess.Popen
getpass.getpass
self.rules.get.endswith
self.seen_values.setdefault
kibana.filters_from_dashboard
smtp.sendmail
datetime.datetime.now
rule_inst.add_terms_data
key.replace
matches.get
self.rules_loader.load_yaml
self.client.transitions
self.get_import_rule
self.content.append
payload.append
should_scrolling_continue
alert.alert
rules.append
jira_field.replace.lower
entries_set.add
self.ref_windows.pop
self.resolve_formatted_key
self.get_starttime
self.get_query_key_value
self.WhitelistRule.super.__init__
matches.self.create_alert_body.strip
self.GoogleChatAlerter.super.__init__
self.cur_windows.setdefault
self.handle_error
self.AlertaAlerter.super.__init__
auth
self.ChangeRule.super.add_match
self.expand_entries
rule_inst.add_data
self.rule_hashes.items
datetime.datetime.utcfromtimestamp
self.get_yaml
self.get_terms_query
self.modify_rule_for_ES5
new_rule_hashes.keys
tracer.addHandler
all
self.logger.info
rule.get.total_seconds
d.replace
field.format
loaded.update
loader_mapping.get
self.occurrences.pop
collections.defaultdict
argparse.ArgumentParser
self.rule.get.get
self.silence
self.get_arbitrary_fields
fh.read.hashlib.sha1.digest
match.update
set
self.client.add_watcher
self.SpikeMetricAggregationRule.super.__init__
identifier.f.replace.lower
k.startswith
value.split
flatten_dict
self.get_index_start
dt_to_unix
match_aggregation.items
tag.format
self._add_rule_text
dt.total_seconds
MIMEText
traceback.format_exc
self.CommandAlerter.super.__init__
ZabbixSender
urllib.parse.quote
iter.get_next
elastalert_logger.warn
es_client.info
self.run_rule
self.logger.exception
add_raw_postfix
session.get_credentials
self._add_top_counts
logging.exception
self.post_payload.items
es.is_atleastsixsix
self.rule.get_match_str
self.thread_data.current_es.is_atleastsixsix
self.disabled_rules.append
self.get_hits_aggregation
self.populate_fields
subkeys.pop
EAException
requests.packages.urllib3.disable_warnings
self.ZabbixClient.super.__init__
es_index.exists
self.client.search_issues
alert_config.items
requests.post
super
values.append
jsonschema.Draft7Validator
payload.items
text_table.set_cols_dtype
timeout.total_seconds
rule.strip.lower
locals
parser.parse_args
jira_field.replace
Exotel
eval
dt.isoformat
TwilioClient
threading.local
self.process_hits
rule_filter.extend
exec_next.datetime.datetime.utcfromtimestamp.replace
is_atleastseven
SMTP
hit.get.items
es_filters.insert
os.path.isfile
yaml.load
json.load
term_data.get
time.sleep
alert_fields.append
self._parse_responders
self.import_rules.pop
e.module_name.EAException.with_traceback
HTMLParser.__init__
include.append
elastalert_logger.setLevel
or_filters.append
self.ExotelAlerter.super.__init__
self.client.create_issue
filters.values
os.path.exists
self.enhance_filter
hit.get
match_json.encode
warnings.resetwarnings
self.smtp.starttls
stale_keys.append
rule.append
self.clear_windows
self.load_yaml
subp.communicate
ElasticSearchClient
self.smtp.login
tb.strip.split
rule.strip
self.info
dt.astimezone
boto3.session.Session
es_index.delete
self.rules.get
self.writeback_es.indices.exists
self.flatten_aggregation_hierarchy
self.thread_data.current_es.search
conf.get
self.rule_hashes.keys
qk.self.cur_windows.append
Env
document.items
self.conf.get
logging.getLogger
self.get_ts.self.rules.EventWindow.self.occurrences.setdefault.append
self.set_starttime
logging.basicConfig
self.get_query
setup
self.sender_port.self.sender_host.ZabbixSender.send
read_es_index_mappings
self.generate_kibana_db
self.data.rotate
issubclass
self.add_match
end.date
payload.copy
new_get_event_ts
self.PercentageMatchRule.super.__init__
self.PagerDutyAlerter.super.__init__
self.find_recent_pending_alerts
datetime.datetime.utcnow.replace
rule_files.append
terms.items
self.garbage_collect
self.create_basic
type
StrideHTMLParser
self.get_ts
self.client.priorities
self.set_priority
self.TelegramAlerter.super.__init__
self.data.append
alert.get_info
top_events.sort
indices.add
self.cur_windows.pop
config_copy.update
croniter
NotImplementedError
Texttable
self.get_aggregation_summary_text
getattr
self.writeback_es.resolve_writeback_index
self.MetricAggregationRule.super.__init__
kibana6_disover_global_state
e.str.strip
os._exit
self.thread_data.current_es.scroll
ts.replace
self.scheduler.modify_job
self.cur_windows.keys
self.alerts_order.get
iter
string.replace
logging.info
counts.sort
elastalert_logger.warning
yaml.safe_dump
prison.dumps
Auth
alert_class
body.update
parse_duration
root.copy
self.smtp.has_extn
self.get_incident_key
rule.get_info
self.OpsGenieAlerter.super.__init__
self.rule.get
flat_match.update
match_timestamp.ts_to_dt.strftime
responder_args.items
isinstance
self.JiraAlerter.super.get_aggregation_summary_text
text_table.header
self.handle_rule_execution
self.VictorOpsAlerter.super.__init__
dt_to_ts
self.writeback_es.is_atleastfive
Elasticsearch
dateutil.tz.tzutc
entry.split
kibana_discover_app_state
ElasticsearchException
self.compare
line.rstrip
elastalert_logger.debug
to_ts_func
self.data.appendleft
es_client.indices.put_mapping
self.matches.append
sys.path.append
strValue.endswith
ts_add
kibana.add_filter
self.EmailAlerter.super.__init__
self.ElasticSearchClient.super.__init__
es.deprecated_search
self.find_pending_aggregate_alert
self.writeback_es.index
alert_config_value.format
conn.disconnect
pytz.timezone
normalize_config
rule.total_seconds
extra.items
self.upload_dashboard
self.set_realert
self.create_alert_body
self.get_priorities
es.index
new_filters.append
sortedlist
self.load_rule_changes
text_table.add_row
self.MsTeamsAlerter.super.__init__
self.get_ts.self.rules.EventWindow.key.self.occurrences.setdefault.append
self.first_event.setdefault
self.JiraAlerter.super.__init__
os.environ.get
self.alert
logging.error
match.items
self.unwrap_term_buckets
self.client.transition_issue
e.EAException.with_traceback
hashable
len
datetime.timedelta
os.path.splitext
self.transport.perform_request
index.rfind
os.path.join
tb.strip
alert_config.update
alert.items
kibana.set_index_name
enhancement
self.scheduler.start
hits_terms.values
self.rule.items
conf.keys
generate_kibana_discover_url
replace_dots_in_field_names
qk.self.cur_windows.count
rule.garbage_collect
DebugAlerter
copy.copy
self.get_account
qk.self.ref_windows.count
self.get_segment_size
query_params
yaml_loader
self.rules_loader.get_hashes
time.time
open
self.handle_uncaught_exception
self.run_every.total_seconds
self.BlacklistRule.super.__init__
key.endswith
key.self.occurrences.count
conn.send
_make_path

Could please help me check this issue? May I pull a request to fix it? Thank you very much.

nsano-rururu commented 1 year ago

elastalert is no longer maintained. Use elastalert2. https://github.com/jertel/elastalert2

nsano-rururu commented 1 year ago

@PyDeps

If you install with "python setup.py install", the library will be installed with the following setup.py settings. The "requirements.txt" you are pointing out is when you install by directly specifying "requirements-dev.txt" or "requirements.txt". "Requirements.txt" is for development and is slightly out of sync with setup.py. elastalert2 is in sync.

        'apscheduler>=3.3.0',
        'aws-requests-auth>=0.3.0',
        'blist>=1.3.6',
        'boto3>=1.4.4',
        'configparser>=3.5.0',
        'croniter>=0.3.16',
        'elasticsearch==7.0.0',
        'envparse>=0.2.0',
        'exotel>=0.1.3',
        'jira>=2.0.0',
        'jsonschema>=3.0.2',
        'mock>=2.0.0',
        'prison>=0.1.2',
        'PyStaticConfiguration>=0.10.3',
        'python-dateutil>=2.6.0,<2.7.0',
        'PyYAML>=3.12',
        'requests>=2.10.0',
        'stomp.py>=4.1.17',
        'texttable>=0.8.8',
        'twilio>=6.0.0,<6.1',
        'cffi>=1.11.5'
nsano-rururu commented 1 year ago

@PyDeps

If you really want to use yelp / elastalert, fork and maintain it yourself. Don't ask other people for help. No one can help. This repository is dead. Please understand that fact first.

nsano-rururu commented 1 year ago

@PyDeps

yelp / elastalert does not support elasticseach8 or opensearch. It doesn't work with python 3.9 / 3.10. Line, zabbix, stomp and pagertree alerts don't work properly. There are many other bugs. If you can't maintain it yourself, use elastalert2.

nsano-rururu commented 1 year ago

@PyDeps

Did you understand?

PyDeps commented 1 year ago

OK